Preferences menu items with QMenu on MacOS
-
I am trying to implement a menu in my project that has the same kind of Preferences menu that VS Code has on MacOS.
Basically VS Code has several menu items listed under Preferences as you can see on the screenshot.I have tried in many ways to achieve that but I didn't have any success. I have also used QAction::setMenuRole but that didn't help.
Could it be that this is a limitation of Qt on MacOS? -
@codeform
My attempt also failed
As soon as you set a submenu, it disappears !action=menu->addAction("Preferences"); action->setMenuRole(QAction::ApplicationSpecificRole); action->setMenu(new QMenu()); // the Preferences menu item vanish
-
Hi,
To the best of my knowledge, the Preferences menu entry shall trigger the apparition of a dedicated dialog.
macOS is the only OS that has it standardized so users do not have to search through many other menues to find it. In order to make things simpler, Qt automatically associates an action named Preferences with that special entry.
-
@SGaist
don't worry I tried with other names,
doesn't work either :(Qt automatically associates an action named Preferences with that special entry.
Yeah it's hardcoded in Qt and I have to say that it is a bug !
I have a windows menu in my apps that lists all open windows included the Prefs dialog.
Starting around Qt5.5, I noticed that the Prefs item vanish from the list and when the Prefs dialog was in front (this item should be checked in the windows list) the Preferences... item in the application menu was checked instead !!!
pure nonsense :(