Fully disable Qt main window including menu bar?
-
21-12-2019 - |
Question
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?
Solution
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);
OTHER TIPS
You should set parent of the menu bar. It should be main window. If parent disabled, actions will be disabled too.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow