Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Mac application menu submenu / ApplicationSpecificRole
Forum Updated to NodeBB v4.3 + New Features

Mac application menu submenu / ApplicationSpecificRole

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 3.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cococarbon
    wrote on last edited by
    #1

    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 ...
    |-About MyApp
    |-MySubmenu
    |-Submenu1
    |-Submenu2
    |-Submenu3
    @

    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!

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      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

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • C Offline
        C Offline
        cococarbon
        wrote on last edited by
        #3

        Thanks for checking, but the fact that setMenuRole doesn't work with submenues is actually well documented in the Qt doco of QAction::MenuRole:
        http://doc.troll.no/4.7/qaction.html#MenuRole-enum

        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.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

          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.

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • C Offline
            C Offline
            cococarbon
            wrote on last edited by
            #5

            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!

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved