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. [solved] Menu bar remains stubbornly invisible on Mac OS X Yosemite
QtWS25 Last Chance

[solved] Menu bar remains stubbornly invisible on Mac OS X Yosemite

Scheduled Pinned Locked Moved General and Desktop
menubarmainwindow
10 Posts 3 Posters 7.7k 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.
  • B Offline
    B Offline
    bereid
    wrote on 19 Aug 2015, 01:13 last edited by bereid
    #1

    I'm a seasoned programmer, but just beginning to learn Qt GUI programming

    I am running Qt 5.5 on Mac OS X Yosemite,

    I have tried several times to create applications via Creator's new project wizard, and selecting Desktop Template=Qt Widgets Application, Build Kit=Desktop Qt 5.5.0 clang 64bit, Base Class=QMainWindow, Generate Form=Checked, and populate the menubar with some simple actions.

    In every case, when I run the resulting executable, the menubar is not visible.

    I am stumped. I have seen this done in YouTube videos, and have attempted to duplicate the steps without success.

    I just duplicated the steps on a Windows 10 machine, and the menubar is visible as expected, so this problem appears to be isolated to my Mac platform. These are the only two machines on which I've installed Qt Creator, so I can't try other platforms, but I'm surprised and somewhat disappointed to find that my very early experience with Qt reveals that these two platforms behave so differently in an aspect as fundamental as the visibility of a menubar.

    Please, I will appreciate any advice to suggest what I'm missing. I'll provide any details about my simple project(s) that might yield a solution, so please just ask, and I will do my best to respond.

    Regards,
    Bruce

    1 Reply Last reply
    0
    • B Offline
      B Offline
      bereid
      wrote on 19 Aug 2015, 03:19 last edited by bereid
      #2

      So, after some additional web searching, I found suggestions that led me to add the following setNativeMenuBar statement in the MainWindow constructor, following the [generated] setupUi statement:

      ui->setupUi(this);
      ui->menuBar->setNativeMenuBar(false);
      

      With this change added, the menubar does appear as expected (and as it does when I do this same sequence in a Windows project).

      But, why must I do this to make the menubar visible on Mac OS? If I don't do this, where should the menubar appear? Because it's not visible at the top of the screen where most other native Mac application menu bars typically appear. It's simply invisible... What's the trick here?

      1 Reply Last reply
      0
      • H Offline
        H Offline
        Huulivoide
        wrote on 19 Aug 2015, 21:13 last edited by
        #3

        Maybe this will help.
        http://stackoverflow.com/questions/26004830/qt-change-application-qmenubar-contents-on-mac-os-x/26008596#26008596

        1 Reply Last reply
        1
        • B Offline
          B Offline
          bereid
          wrote on 21 Aug 2015, 23:57 last edited by
          #4

          Thank you for that reference. Though it didn't directly lead me to a solution, it did offer some interesting details.

          1 Reply Last reply
          0
          • B Offline
            B Offline
            bereid
            wrote on 22 Aug 2015, 00:06 last edited by
            #5

            I concluded that the menubar was not showing because I wasn't looking in the right place for this [particular] menu action. During my testing, I implemented only a single menu action (Help|About). It turns out that this action shows up on the Mac native menubar in the column below the application name; there is no independent heading on the menubar with the label 'Help'. This was subtly deceptive, and led me on this goose chase.

            I didn't find this documented anywhere, but discovered it while exploring the menus example app bundled with the Qt 5.5 distribution. Playing with that example code was very informative.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 22 Aug 2015, 22:08 last edited by
              #6

              Hi,

              You have more information about the OS X specific menu bar handling the QMenuBar documentation here

              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
              1
              • B Offline
                B Offline
                bereid
                wrote on 24 Aug 2015, 01:11 last edited by
                #7

                @SGaist said:

                here

                Yes, I do see some helpful information there. Thank you!

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 24 Aug 2015, 21:01 last edited by
                  #8

                  You're welcome !

                  Since you have the bar working now, please update the thread title prepending [solved] so other forum users may know a solution has been found :)

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

                  B 1 Reply Last reply 25 Aug 2015, 17:21
                  0
                  • S SGaist
                    24 Aug 2015, 21:01

                    You're welcome !

                    Since you have the bar working now, please update the thread title prepending [solved] so other forum users may know a solution has been found :)

                    B Offline
                    B Offline
                    bereid
                    wrote on 25 Aug 2015, 17:21 last edited by
                    #9

                    @SGaist I have edited the title to indicate it is solved, as you requested. I had actually already appended the [solved] text earlier, as I had observed in some other posts. After seeing your comment that it should be prepended, I'll remember that for the future.

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 25 Aug 2015, 19:48 last edited by
                      #10

                      IIRC, having at first position allows the forum to show it more nicely on the lists

                      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

                      7/10

                      24 Aug 2015, 01:11

                      • Login

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