QMenuBar and QMenu doesn't show in Mac OS X

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-04 12:05:33

There is no problem in the code, nor in Qt. The example you cite only creates an Exit action in the menu. On OS X, such actions belong in the application menu, not in the File menu. Your application is called qt_menu, and that's how the application menu is called, and that's where you will find the Quit action -- Qt has correctly renamed it to agree with Apple's HIG. On Windows, it'd be customary to call it Exit, on a Mac it's bad style. Qt's behavior is correct, and I can reproduce it.

Add other actions to the file menu, or simply rename the one action from Exit to something else.

Note that Qt doesn't move actions directly based on their name. Qt guesses the action roles based on their name. You should override such guesses and set action roles explicitly using QAction::setMenuRole(). Those roles then get interpreted appropriately on various platforms.

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