Martin Delille
Martin Delille

Reputation: 11810

QML menu bar display in QtQuick application

I'm developing a macOS application using QML containing just a menu bar:

import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.4

ApplicationWindow {
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")

    menuBar: MenuBar {
        Menu {
            title: qsTr("&File")
            Action { text: qsTr("&New...") }
            Action { text: qsTr("&Open...") }
            Action { text: qsTr("&Save") }
            Action { text: qsTr("Save &As...") }
            MenuSeparator { }
            Action { text: qsTr("&Quit") }
        }
        Menu {
            title: qsTr("&Edit")
            Action { text: qsTr("Cu&t") }
            Action { text: qsTr("&Copy") }
            Action { text: qsTr("&Paste") }
        }
        Menu {
            title: qsTr("&Help")
            Action { text: qsTr("&About") }
        }
    }
}

Unfortunately, the menu doesn't look as expected:

screenshot

Usually, menu items appear next to the Apple menu which contains just MenuTest here:

enter image description here

Upvotes: 3

Views: 1646

Answers (1)

dtech
dtech

Reputation: 49329

You are using the "stock" menu from Controls - it is not a "native" menu.

You can opt to use the one provided by Qt.labs.platform.

Keep in mind this will drag the QtWidgets module as a project dependency.

Upvotes: 4

Related Questions