I'd like to create a Menu in QML application that has other Menus depending on some Model. When I use Instantiator for that, items which are being created are parented to the Instantiator itself and when adding them to top-level Menu, it complains about `__parentMenu` being null
Menu {
title: qsTr("Top-Level Menu")
id: topMenu
Instantiator {
model: aTopLevelModel
onObjectAdded: topMenu.insertItem( index, object )
onObjectRemoved: topMenu.removeItem( object )
delegate: Menu {
id: innerMenu
title: qsTr("Inner Menu")
Instantiator {
model: aTopLevelModel.getInnerModel(index)
onObjectAdded: innerMenu.insertItem( index, object )
onObjectRemoved: innerMenu.removeItem( object )
delegate: MenuItem {
text: qsTr("Menu action!")
onTriggered: {
console.log("Action of inner menu")
}
}
}
}
}
}
Menu {
title: qsTr("Top-Level Menu")
id: topMenu
Instantiator {
model: aTopLevelModel
onObjectAdded: topMenu.insertItem( index, object )
onObjectRemoved: topMenu.removeItem( object )
delegate: Menu {
id: innerMenu
title: qsTr("Inner Menu")
Instantiator {
model: aTopLevelModel.getInnerModel(index)
onObjectAdded: innerMenu.insertItem( index, object )
onObjectRemoved: innerMenu.removeItem( object )
delegate: MenuItem {
text: qsTr("Menu action!")
onTriggered: {
console.log("Action of inner menu")
}
}
}
}
}
}
To copy to clipboard, switch view to plain text mode
The warning I'm observing is:
Menu.qml:149: TypeError: Cannot read property '__contentItem' of null
Menu.qml:149: TypeError: Cannot read property '__contentItem' of null
To copy to clipboard, switch view to plain text mode
Where the line 149 is
property var __parentContentItem: __parentMenu.__contentItem
property var __parentContentItem: __parentMenu.__contentItem
To copy to clipboard, switch view to plain text mode
How can I overcome this Warning being produced?
Qt version is 5.5.1. This behavior is observed undre OS X and Windows versions of Qt.
Bookmarks