How do I dynamically add a new menu item to a menu?
-
I use the following example to make an error in QT5.9.7.
What went wrong in the following example?import QtQuick 2.9 import QtQuick.Controls 2.3 import QtQuick.Window 2.2 ApplicationWindow { visible: true width: 640 height: 200 title: qsTr("Hello World") id:root MouseArea { anchors.fill: parent onClicked: { menu.addEntry('test') menu.open() } } Menu { id: menu function addEntry(title) { menu.addItem(menuItem.createObject(menu, { text: title })) } Component { id: menuItem MenuItem { text: title } } }
-
@mirro
Instantiators are much cleaner.https://stackoverflow.com/questions/45652525/qml-filling-menu-with-model-items
@Markkyboy is telling you to search and research your problem more. We have been getting a LOT of low effort posts and it wears on your patience.
-
-
@mirro
Instantiators are much cleaner.https://stackoverflow.com/questions/45652525/qml-filling-menu-with-model-items
@Markkyboy is telling you to search and research your problem more. We have been getting a LOT of low effort posts and it wears on your patience.
-
@mirro said in How do I dynamically add a new menu item to a menu?:
What went wrong in the following example?
Is this some kind of brain twister?
Don't you think you should tell others what is not working instead to ask others to find out by themself?
Please ask understandable questions...