3

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

Christopher Oezbek
  • 23,994
  • 6
  • 61
  • 85
Martin Delille
  • 11,360
  • 15
  • 65
  • 132

1 Answers1

4

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.

dtech
  • 47,916
  • 17
  • 112
  • 190