Application menu is enabled even if a modal dialog box is open

喜夏-厌秋 提交于 2019-12-11 08:13:59

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!