Reputation: 338
I created a QML app under Mac, but I don't know what happens when I click the about menu.
In http://doc.qt.io/qt-5/qmenubar.html, we find things about QMenuBar on OS X. But what's the corresponding QML method?
Currently, my code is:
Menu {
title: qsTr("&File")
MenuItem {
text: qsTr("&Open")
onTriggered: messageDialog.show(qsTr("Open action triggered"))
}
MenuItem {
text: "about.*"
onTriggered: console.debug("FDF")
}
MenuItem {
text: qsTr("E&xit")
onTriggered: Qt.quit()
}
}
When I execute, this menu only shows Open, and About and Exit are correctly integrated into the mac menu. The exit is fine, but when I click about, it just quits normally.
So how do we handle that?
Upvotes: 1
Views: 1027
Reputation: 1
menuBar: MenuBar {
Menu {
title: qsTr("&File") // Name
MenuItem {
text: qsTr("&Open") // Name
onTriggered: messageDialog.show(qsTr("Open action triggered")) // Action on Triggered
}
MenuItem {
...
}
}
}
Upvotes: -1
Reputation: 338
I found the problem. My code is like this,
menuBar: MenuBar {
Menu {
title: qsTr("&File")
MenuItem {
text: qsTr("&Open")
onTriggered: messageDialog.show(qsTr("Open action triggered"))
}
MenuItem {
text: "about.*"
onTriggered: console.debug("FDF")
}
MenuItem {
text: qsTr("E&xit")
onTriggered: Qt.quit()
}
}
Menu {
title: qsTr("&Help")
MenuItem {
text: qsTr("&Help")
onTriggered: messageDialog.show(qsTr("Open action triggered"))
}
MenuItem {
text: qsTr("&About")
onTriggered: Qt.quit()
}
}
}
There are two about
menu items, and the latter overrides the previous one.
Upvotes: 3