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. Os X native menu bar not populated on first show
QtWS25 Last Chance

Os X native menu bar not populated on first show

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 1.8k Views
  • 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.
  • G Offline
    G Offline
    gh2k
    wrote on last edited by
    #1

    I'm having an issue with my menubar on a QMainWindow, on Os X.

    After my window is shown the global menu bar is not correctly populated. There is the main application with About/Preferences/Quit present (all of which work) but I'm not seeing any of my other menus. (File, Edit, View etc...)

    Switching focus to another window and back again repopulates the global menu correctly. (Switching to another app, opening the preferences dialog and closing it again...)

    If I turn native menus off then they appear just fine along the top of the window, but this is not really optimal.

    I've tried various bits of trial and error including turning native menus off until showEvent, and then turning back on... Calling setMenuBar in showEvent to reset the menu, trying to activateWindow in showEvent... I'm not really sure what I'm doing though and this is mostly guesswork.

    Has anyone seen this before? If so, how did you fix it? Google suggests it's not a very common problem.

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

      HI and welcome to devnet,

      You should also share which edition of OS X you are using as well as Qt version.

      Also, you should post the code where you setup your menu

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

        It's Qt 5.4 on 10.10...

        The menu is created as part of the mainwindow .ui file. There's nothing special to initialise it after that apart from connecting slots to actions.

        Obviously this usually works, but something must be getting in the way. It's an oss project I'm trying to get working on osx so I'm not familiar with the fine details of it. There's a big class that does a bunch of stuff here: https://github.com/mfeemster/fractorium/blob/master/Source/Fractorium/Fractorium.cpp -- but there's a lot of code so you'd be forgiven for not looking at it. :-)

        What I'm really wondering is whether anyone has seen this before, or knows enough about the menubar internals to explain how I can force the global menu bar to refresh itself from the one that's there? -- It obviously works when the window is refocused, but I'd like to "simulate" this at the point where it's gone wrong.

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

          From a quick overlook of the files and the menu related code, nothings stands out that could trigger that. Can you check if you still have this with Qt 5.5 ?

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

          G 1 Reply Last reply
          0
          • SGaistS SGaist

            From a quick overlook of the files and the menu related code, nothings stands out that could trigger that. Can you check if you still have this with Qt 5.5 ?

            G Offline
            G Offline
            gh2k
            wrote on last edited by
            #5

            @SGaist I've just tried it with 5.5 instead of 5.4, but it didn't make a difference unfortunately. :/

            1 Reply Last reply
            0
            • G Offline
              G Offline
              gh2k
              wrote on last edited by
              #6

              For anyone landing here from google, I worked around this by saying emit qGuiApp->onFocusWindowChanged(windowHandle()); in my main window's show event.

              The method to update the native window is hooked up to this event.

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

                Thanks for the workaround but it's fishy at best. There might be some bug lurking around

                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