Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Os X native menu bar not populated on first show

    General and Desktop
    2
    7
    1372
    Loading More Posts
    • 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
      gh2k last edited by

      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 Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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 Reply Quote 0
        • G
          gh2k last edited by

          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 Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by 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 ?

            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 Reply Quote 0
            • G
              gh2k @SGaist last edited by

              @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 Reply Quote 0
              • G
                gh2k last edited by

                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 Reply Quote 0
                • SGaist
                  SGaist Lifetime Qt Champion last edited by

                  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 Reply Quote 0
                  • First post
                    Last post