Mac application menu submenu / ApplicationSpecificRole
Hi. I need to add a submenu to the application menu on the mac but the documentation explicitly says that setting the QAction::ApplicationSpecificRole on it won't work for actions that are in a submenu. This is what I want my menu to look like:
@MyApp File Edit ...
Where the "MyApp" menu is the application menu (not added by me).
Ideally there would be a function or method you can call to get the QMenu* for the application menu? Please help!
Just tried it. A single QAction does show up in the application menu. Additionally, you have "QAction::setMenu() ":http://doc.qt.nokia.com/4.7/qaction.html#setMenu, but as soon as there is a submenu on that action the whole action disappears.
Seems to be a bug. I'd suggest to open a bugreport on the "bug tracker":http://bugreports.qt.nokia.com
Thanks for checking, but the fact that setMenuRole doesn't work with submenues is actually well documented in the Qt doco of QAction::MenuRole:
What I wanted to know is if there's anything else. For example, I would love to have something like QMenu * QApplication::macAppMenu(), where I can then add/insert actions and menus myself. Or perhaps a menuRole kind of thing you can set up on my submenu, so the whole submenu gets moved across to the application menu.
I interpreted the docs, that an action in a submenu cannot be moved to the application menu. But from my understanding it should be possible to move an action that has a menu applied via setMenu() to the application menu and it should keep its submenu.
As far as I know, the application menu magic is behind the scenes and uses native calls to cocoa/carbon and there is no QMenu pointer representing the app menu.
I see no way to achieve your goal at the moment :-/
The best way would be to make a QAction with submenu working.
Thanks for that. I think you're right. I kind of expected it, but I had to try... had to make sure I didn't overlooked something :) One option is to change it in the source to do what you say, which sounds like a good idea (QAction with submenu) but in the meantime I'll stick my submenu inside the "File" menu, which is not great but in our case it's "OK". Cheers!