'Create simple starter menu QtQick/QML
I want to create menu of buttons in QML with simple animation Simple QML Menu
When I add a button after another I only get the last one
Edit: I added this code also but everytime I click any button the menu disappears
import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.15
Window {
width: 640
height: 480
visible: true
title: qsTr("Hello World")
Menu {
id: menu
visible: true
MenuItem {
Button{
text:"Play"
}
}
MenuItem {
Button{
text:"Play"
}
}
MenuItem {
Button{
text:"Sett"
}
}
}
}
Solution 1:[1]
A MenuItem already derives from AbstractButton, so there's no point in adding a Button as a child of the MenuItem.
The docs show many simple examples, like this:
Menu {
id: menu
MenuItem {
text: "New..."
onTriggered: document.reset()
}
MenuItem {
text: "Open..."
onTriggered: openDialog.open()
}
MenuItem {
text: "Save"
onTriggered: saveDialog.open()
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | JarMan |
