问题
I have an application where I can launch a modal dialog box over a main window. The main window has some network activity going on in background which updates my background UI. Due to this the application menu becomes accessible even if the modal dialog is open.
How can I avoid this? Any help is appreciated.
I am using Mac, Qt, Carbon.
回答1:
You can't disable Application menu on Mac OS X, it's always "active" BUT you can disable actions you don't want to be used while dialog is visible
回答2:
You can have the modal dialog create its own menubar, which will override the the mainwindow's while the dialog is shown.
If you don't want to allow any actions, just create an empty QMenuBar with the dialog as its parent. You don't even have to show it. Qt will find it and promote it to the global menu bar automagically.
回答3:
I had similar problem in Ubuntu, so may be this will solve your problem in Mac OS X as well. It is simple, just disable the QMenu.nativeMenuBar
property of the main menu bar, i.e. menuBar->setNativeMenuBar(false)
. See the accepted answer here: Global application menu active in modal dialog box (on Linux)
来源:https://stackoverflow.com/questions/2452367/application-menu-is-enabled-even-if-a-modal-dialog-box-is-open