Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
6.3.0, 6.4.1
-
None
-
Ubuntu Linux 22.04
-
-
239082b5a (dev), 032af80b4 (6.5)
-
DaVinci 69, DaVinci 70
Description
According to the docs there is option to add an MenuItem to the menu. This implies that I have to create MenuItem dynamically too. So far I've created a simple test code:
Row { anchors.centerIn: parent Button { id: button text: "Menu" onClicked: menu.open() Menu { id: menu } } Button { text: "Add item" onClicked: { var item = menuItem.createObject(menu, {text: "New item"}); menu.addMenu(item); } } }
This code crashed with error:
Created graphical object was not placed in the graphics scene
The same thing happens in Qt 5.15 but with more detailed error:
QQmlComponent: Created graphical object was not placed in the graphics scene. "Could not convert argument 0 at" "onClicked@qrc:/main.qml:32" "Passing incompatible arguments to C++ functions from JavaScript is dangerous and deprecated." "This will throw a JavaScript TypeError in future releases of Qt!"
Probably the parent of MenuItem is some inner item of the Menu. So what a way to create an menu item dynamically?
Attachments
Issue Links
- relates to
-
QTBUG-134936 Improve imperative Menu API documentation
-
- Reported
-