0

I need to temporarily disable the main window, including the menu bar. The main window can be disabled simply using setEnabled(false) however it seems that doesn't disable the menu bar, so the user can still click menu items (which in my case break the application).

Is there any way to completely disable all user interactions, including the menu bar?

laurent
  • 88,262
  • 77
  • 290
  • 428

2 Answers2

2

Calling setEnabled(false) in main window also disables menu bar. Any way you can also use setEnabled method of QMenuBar class :

ui->menuBar->setEnabled(false);
Nejat
  • 31,784
  • 12
  • 106
  • 138
  • Hmm... calling `menuBar()->setEnabled(false)` removes the menu bar, however calling `setEnabled(true)` doesn't bring it back. Is that the expected behavior? – laurent Aug 01 '14 at 05:12
  • No. When I call `menuBar()->setEnabled(false)` it gets just disabled. That's weird. – Nejat Aug 01 '14 at 05:25
1

You should set parent of the menu bar. It should be main window. If parent disabled, actions will be disabled too.

cassandrad
  • 3,412
  • 26
  • 50