Description
// Creating a new cube by clicking cylinder won't printout click event. // However, if the cube is created dynamically in Component.onCompleted it printouts click event. // With 'showPicking: true' it can be seen that there's no color(=black) associated to the dynamically created component. import QtQuick 1.0; import Qt3D 1.0 import Qt3D.Shapes 1.0 Viewport { id: view width: 800; height: 480 picking: true showPicking: true function showCube() { // Dynamic object created. Picking the new object is not possible. var newObject = Qt.createQmlObject('import QtQuick 1.0; import Qt3D 1.0; import Qt3D.Shapes 1.0; Cube { position.x: Math.random(); position.y: Math.random(); onClicked: {console.log("Cube clicked"); }}', view, "dynamicSnippet1"); view.update3d(); } Cube { scale: 3.5 transform: [ Scale3D { scale: Qt.vector3d(800/480,1.0, 0.1) } ] position.z: -2 } Cylinder { position.x: 1 position.y: 1 position.z: 1 radius: 0.5 length: 3.0 effect: Effect { color: "#aaca00" } onClicked: { view.showCube(); } } Component.onCompleted: { view.showCube(); } }
Attachments
Issue Links
- depends on
-
QTBUG-20053 Picking for Objects Created by Repeater
- Closed