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, 4.8.5: QAction in main menu not obeying AboutRole menu role [Solved]
Forum Updated to NodeBB v4.3 + New Features

Mac, 4.8.5: QAction in main menu not obeying AboutRole menu role [Solved]

Scheduled Pinned Locked Moved General and Desktop
11 Posts 2 Posters 2.8k 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.
  • J Offline
    J Offline
    janfaroe
    wrote on last edited by
    #1

    Hi all,

    when triggering the "About..." item in the Applications menu, the corresponding slot does not get called; instead a completely unrelated slot gets called.

    In Qt Creator, the menu item resides under the "Help" menu. On the Mac, menu items with the role QuitRole, AboutRole or PreferencesRole is automatically moved to the Applications menu, which does not happen for the AboutRole in my case. I still see the menu item under the "Help" menu, and here the correct slot is called. The other roles works as expected.

    I quadruple checked, and the QAction in question does have role set as AboutRole, see below.
    It's an application ported from 5.2, and as I recall, it worked in 4.8.4. I don't have the opportunity to test in 4.8.4.

    Any suggestions/ideas?

    Edit: Snippet from the .ui file defining the QAction. I can't see any funkiness compared to the others:

    @<action name="actionAbout">
    <property name="text">
    <string>About</string>
    </property>
    <property name="visible">
    <bool>true</bool>
    </property>
    <property name="menuRole">
    <enum>QAction::AboutRole</enum>
    </property>
    </action>@

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

      Hi,

      I'm not sure I am following you properly so:

      It's working properly with Qt 4.8.4 but not 4.8.5, is that right ?

      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
      • J Offline
        J Offline
        janfaroe
        wrote on last edited by
        #3

        I have rewritten my post. It was late.

        As I recall, yes, but it's been a while. At least it worked in 5.x.

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

          Just tried with a little dummy app but it seems to be working. Do you have a minimal example that I could try ?

          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
          • J Offline
            J Offline
            janfaroe
            wrote on last edited by
            #5

            Just tried the same; works in a new project. I'll try to boil my project down to a minimal main window example.

            1 Reply Last reply
            0
            • J Offline
              J Offline
              janfaroe
              wrote on last edited by
              #6

              Found the problem. As per http://qt-project.org/doc/qt-4.8/qmenubar.html#qmenubar-on-mac-os-x , menu item texts containing the string "about*" automatically gets assigned the menu role, and moved to the "appropriate" place. The problem is, my application is a browser-like application with dynamically loaded browser bookmark and history menus. Guess what? Some of the items were from "about.com", which explains that when I triggered the "About..." menu item, the page from about.com gets loaded. Sort of explains everything.

              But - both QAction::setMenuRole(QAction::NoRole) and QAction::setMenuRole(QAction:: TextHeuristicRole) on the dynamic items are being ignored. They are still triggered by the "About..." menu item.
              I'm pretty sure this was ok in Qt4.8.4.

              Am I overseeing something here? I just need ONE Qt version that works properly on the Mac, then I would be happy. If I'm not overseeing something, then I'm out options, and will start porting my application to pure c or assembly language. That would probably be less frustrating.

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

                Can you post a minimal QAction setup that shows this behavior ?

                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
                • J Offline
                  J Offline
                  janfaroe
                  wrote on last edited by
                  #8

                  Nope, thankfully :-D

                  Created a minimal example, turns his the menu role HAS to be QAction::NoRole, QAction::TextHeuristicRole won't cut it. Once I changed this consistently in my application, it worked.

                  Thanks ;-)

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

                    Great ! :)

                    Thanks for sharing the solution.

                    You could add a doc note on QAction explaining this, that might help others :)

                    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
                    • J Offline
                      J Offline
                      janfaroe
                      wrote on last edited by
                      #10

                      Done for 4.8 :-)

                      http://qt-project.org/doc/qt-4.8/qaction.html

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

                        Nice, thank you !

                        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

                        • Login

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