Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
MacOs, How to implement Preference menu to open custom dialog?
JohnGa last edited by JohnGa
I have an openPreferences action defined in the form. Within the form, the openPreference action is connected to the openPreferencesDialog slot. This works perfectly on all platforms, except on Mac.
I also have other menus with "QuitRole", and "AboutRole". These work perfectly, even on Mac.
As per documentation, the openPreferences action has a menuRole of "PreferencesRole". On macOs, it renders "Preferences..." under the application menu. However, the "Preferences..." menu always invokes some other slot in the application (and not the openPreferencesDialog slot).
When I set, "menuBar->setNativeMenuBar(false)", the menuBar gets painted within the application window. There is a "Preferences" menu in the application window, and "Preferences..." menu in the Mac application menubar at the top. Both the "Preferences" menus correctly open the preferences dialog. But, this makes for very bad user experience.
My understanding is that Qt does preprocessing and moves the menus around for macOs. What am I doing wrong in OPTION 1? How can I get that to work?
Please show the code you use to build your menus.
JohnGa last edited by
@SGaist I used this link where you had also posted info.
The key was to set the parent of the menuBar to null. That resolved the problem.