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 desktop integration and qt_mac_set_menubar_merge( bool )

Mac desktop integration and qt_mac_set_menubar_merge( bool )

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 2.0k 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.
  • R Offline
    R Offline
    rcari
    wrote on last edited by
    #1

    Hi all,

    I am currently in the process of "porting" a C++ application to Qt5 and all its amazing amazements. It is a windowless app, with only a QSystemTrayIcon giving information about a simple background process. When built against Qt 4.8.4 the "Quit", "Settings" and "About" menus are shown in the context menu associated with the tray icon. However, when built against Qt 5.0.0, the same menus items simply disappear.
    I found that odd but remembered that Qt does some work for you to follow Mac OS X user interface guidelines when it comes to those menu items. As I don't have any windows, I chose not to have a dock icon, and by extension no menu bar. This makes those quite useful menu items simply inaccessible to the user. Bummer...

    So I looked up the documentation for the method: @qt_mac_set_menubar_merge( bool )@
    Although this method is clearly documented, it is nowhere to be found in Qt 5.0.0 (it is available in 4.8.4).

    I know this symbol is not publicly defined in the Qt headers by default so I defined it myself. With Qt 4.8.4 at link time the symbol is found and I can build the application. The problem with Qt 5.0.0 is that this very same symbol can't be found at link time.
    I scanned the latest Qt 5.0.1 source code for it and found that it can only be found in an example "languagechooser.cpp" source code surrounded by the @#ifdef Q_WS_MAC@
    guard which has been deprecated in Qt 5, and in the documentation generation files. Second bummer...

    My understanding is that this method is no longer part of the Qt API as of 5.0.0, however I am stuck with no solution when it comes to solving that issue. Did similar options move to other parts of the API ? If yes where ?

    Thanks in advance to anybody who can help me with this.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      IIRC the lib is qtmacextras (there is also one for windows and X11). The platform very specific stuff have been move the *extras libraries (you should find them on gitorious)

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rcari
        wrote on last edited by
        #3

        Well I found a solution to my problem:
        @QMenu* menu = new QMenu();

        // Settings
        QAction* action;
        action = menu->addAction( tr( "Settings" ), this, SLOT( settings() ) );
        action->setMenuRole( QAction::NoRole );

        // About
        action = menu->addAction( tr( "About" ), this, SLOT( about() ) );
        action->setMenuRole( QAction::NoRole );

        // Quit
        action = menu->addAction( tr( "Quit" ), qApp, SLOT( quit() ) );
        action->setMenuRole( QAction::NoRole );@

        The @setMenuRole( QAction::NoRole )@ did the trick!

        1 Reply Last reply
        0
        • P Offline
          P Offline
          PysCowboy
          wrote on last edited by
          #4

          qt_mac_set_menubar_merge() seems not to be a part of QtMacExtras:

          @$ cd qtmacextras
          $ fgrep qt_mac_set_menubar_merge * -R

          no output@

          1 Reply Last reply
          0
          • P Offline
            P Offline
            PysCowboy
            wrote on last edited by
            #5

            ... and the
            @setMenuRole( QAction::NoRole )@

            trick doesn't do the job in my environment (Qt 5.1.0)

            1 Reply Last reply
            0
            • P Offline
              P Offline
              PysCowboy
              wrote on last edited by
              #6

              Ok, the correct answer is now to set specifically the menuRole rather than QAction::NoRole. For example:

              @// About
              action = menu->addAction( tr( "About" ), this, SLOT( about() ) );
              action->setMenuRole( QAction::Preferences );@

              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