Is there any way to add standard About
and Preferences...
menu items using Qt Quick Controls 2?
Qt version 5.7, macOS Sierra 10.12.2
Check out Menu
and MenuItem
from Controls 2
.
Button {
id: fileButton
text: "File"
onClicked: menu.open()
Menu {
id: menu
y: fileButton.height
MenuItem {
text: "New..."
}
MenuItem {
text: "Open..."
}
MenuItem {
text: "Save"
}
}
}
Controls 2 doesn't appear to have a MenuBar
element thou. But it is essentially just a row of buttons which open menus plus a filler for the bar, anchored to the top of the window. So you can easily do it yourself.
The downside of using controls 2 is that it doesn't seem to support native menu styles.
Good news - the upcoming 5.8 release will come with the Qt.labs.platform
module, which provides platform native controls, there is a menu bar, menu, menu item, menu groups and separators.