Error adding a Menu in QML
I have the following code:
import QtQuick 2.4 import QtQuick.Window 2.2 import QtQuick.Dialogs 1.2 import QtQuick.Controls 1.4 ApplicationWindow { title: qsTr("Hello World!") width: 640 height: 480 visible: true menuBar: MenuBar { id: menuBar } MouseArea { anchors.fill: parent onClicked: { menuBar.menus.addItem("test") } } }
When I run it and click, the following message appears:
qrc:/main.qml:19: TypeError: Property 'addItem' of object [object Object] is not a function
Why is this?
This one is discussed on ; there's some stuff there on how hard (impossible?) it is to dynamically add a Menu to a MenuBar, but maybe we're both missing some other trick.