OS X Unified toolbar Preferences not working
-
I'm not an Mac user so please forgive me if I'm using wrong terminology or if I'm missing something very obvious.
I have a Qt application which works very well on Windows and Linux. Now I'd like to add OS-X support (I want to provide a pre-build package/bundle).
In myQMainWindow
I have twoQMenu
with the following entries to open dialogs: File -> Preferences and Project -> Settings. The idea is that thePreferences
are the application preferences themselves where theSettings
are the settings of the project that is currently opened in the application.
Apparently the unified toolbar recognizes thePreferences
menu entry and moves it from theFiles
menu to a different menu entry (the application entry which is written in bold).
My main problem is that theSettings
menu entry which used to be in theProject
menu is gone completely. Furthermore thePreferences
menu entry is disabled. This is due to the fact that I disable theProject -> Settings
menu entry if there's no project loaded in the application. This indicates that the unified toolbar also messes around with theSettings
entry.I have absolutely no idea what causes this issue and whether it's supposed to be that way or whether it's a bug. I would appreciate any kind help to resolve this issue.
-
Wild guess here:
Try settingQt::AA_DontUseNativeMenuBar
as Application Attribute -
@VRonin Thank you for your suggestion!
Interestingly that doesn't have any effect. The application still uses the unified menubar.
I set the attribute like this in mymain()
before I construct and show theQMainWindow
:QCoreApplication::setAttribute(Qt::AA_DontUseNativeMenuBar, true);
Interestingly I get the following debug messages in the application output pane when opening and closing the application when the attribute is set to true:
Menu item is already in a menu, remove it from the other menu first before inserting Menu item is already in a menu, remove it from the other menu first before inserting Menu item is already in a menu, remove it from the other menu first before inserting Menu item is already in a menu, remove it from the other menu first before inserting Item to remove does not belong to this menu Item to remove does not belong to this menu Item to remove does not belong to this menu Item to remove does not belong to this menu
I also tried
QMainWindow::setUnifiedTitleAndToolBarOnMac()
but without any success either. The application still uses the unified toolbar.I'm using Qt 5.6 on OS X 10.11.4 (El Capitan)