Menu bar does not show up in Mac Qml application after upgrading from Qt6.7.0 to 6.8.0
-
I have a fairly simple Qt/Qml C++ application.
After upgrading to from Qt6.7.0 to Qt6.8.0 the menubar does not show up on Mac
When building the same application for Windows and Linux, using Qt6.8.0 the menubar shows up, like it did with Qt6.7.0 -
This post is deleted!
-
Hi and welcome to devnet,
Which version of macOS is it ?
Please provide a minimal compilable example that shows this behaviour. -
Hi and welcome to devnet,
Which version of macOS is it ?
Please provide a minimal compilable example that shows this behaviour.@SGaist than you for the reply
It is macOS Sonoma 14.6.1 on a M2 Pro, compiled with Clang 15.0.0 arm64-apple-darwin23.6.0
I have not created a minimal example yet, but wanted to know it if was a known issue
-
Hi, can you provide a screenshot of the before / after? Do you mean that the global menu bar is empty, or did you have a menu bar in one of your windows itself which is now moved to the global menu bar (or not shown at all)?
@IgKh Thank you for the reply
The global menu is no longer present.
It is a fairly small mastermind game application, that I have written to get to learn Qt.
it is the same Qml and C++ source code for all platforms (which is one of the reasons for testing Qt)The menubar in qml is
ApplicationWindow { menuBar: MenuBar { Menu { title: "&Mode" Action { text: "&Demo" onTriggered: boardWindow.model.onSetAutomaticMode() } Action { text: "&Computer Knows Secret" onTriggered: boardWindow.model.onSetEvaluateMode() } Action { text: "&User Knows Secret" onTriggered: boardWindow.model.onSetGuessMode() } } Menu { title: "&Hint" enabled: model.codePegHintEnabled Repeater { model: 4 MenuItem { text: (index + 1) + " Color " + (index == 0 ? "Peg" : "Pegs") onTriggered: boardWindow.model.onHint(index+1); } } } }
-
Might sound silly but are you explicitly setting it to non default on macOS ?
On this platform the menu bar is at the top of the screen and not the application window. -
Might sound silly but are you explicitly setting it to non default on macOS ?
On this platform the menu bar is at the top of the screen and not the application window.@SGaist thank you so much
That is not silly at all. That is the explanation.
The menu is on the top of the screen with Qt 6.8.0
I don't know why I didn't look there. It was just used to the menu being shown in the application window on all 3 platforms.I have not explicit set it to non default behavior.
As shown in the code, the menu is defined as a child of the ApplicationWindow in Qml. Isn't that the normal way of doing it ?
I wonder why the behavior has changed from Qt 6.7.1 to Qt 6.8.0 -
@SGaist thank you so much
That is not silly at all. That is the explanation.
The menu is on the top of the screen with Qt 6.8.0
I don't know why I didn't look there. It was just used to the menu being shown in the application window on all 3 platforms.I have not explicit set it to non default behavior.
As shown in the code, the menu is defined as a child of the ApplicationWindow in Qml. Isn't that the normal way of doing it ?
I wonder why the behavior has changed from Qt 6.7.1 to Qt 6.8.0@Mogens-Hansen That's where macOS users expect application menus to be; that it wasn't this way earlier could be considered a defect in Qt Quick (I searched around and found several forum topics ans stack overflow questions complaining about QML application menus not moving to the global menu bar).
The project ticket for the change in Qt 6.8 seems to be https://bugreports.qt.io/browse/QTBUG-69558; though it is not clear to me why this change isn't in the release notes.
If you want it to be keep being like it was before, you can set the
Qt::AA_DontUseNativeMenuBar
attribute on yourQGuiApplication
. -
@Mogens-Hansen That's where macOS users expect application menus to be; that it wasn't this way earlier could be considered a defect in Qt Quick (I searched around and found several forum topics ans stack overflow questions complaining about QML application menus not moving to the global menu bar).
The project ticket for the change in Qt 6.8 seems to be https://bugreports.qt.io/browse/QTBUG-69558; though it is not clear to me why this change isn't in the release notes.
If you want it to be keep being like it was before, you can set the
Qt::AA_DontUseNativeMenuBar
attribute on yourQGuiApplication
.@IgKh Thank you very much. That makes a lot of sence.
I agree that the previous behavior can be considered a defect.
I wonder why I didn't notice that before, but I think I was happy that it looked the same on all 3 platforms