Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[solved] Menu bar remains stubbornly invisible on Mac OS X Yosemite
bereid last edited by bereid
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.
bereid last edited by bereid
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:
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?
Huulivoide last edited by
Thank you for that reference. Though it didn't directly lead me to a solution, it did offer some interesting details.
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.
You have more information about the OS X specific menu bar handling the QMenuBar documentation here
Yes, I do see some helpful information there. Thank you!
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 :)
@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.
IIRC, having at first position allows the forum to show it more nicely on the lists