I want to dynamically build a QML context menu. When I call 'addMenu' the menu entry is added, but I get this warning:
QQmlComponent: Created graphical object was not placed in the graphics scene.
Here is the code to reproduce the issue:
import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Window 2.2
import QtQuick.Dialogs 1.2
ApplicationWindow {
title: qsTr("Hello World")
width: 640
height: 480
Menu {
id:contextMenu
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.RightButton
onClicked: {
contextMenu.addMenu("NewMenu");
contextMenu.popup();
}
}
}
What am I doing wrong here?
contextMenu.insertMenu(contextMenu.__currentIndex,"NewMenu")- Mido