Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-18585

qml3d: from user event dynamically created objects are not pickable

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • Qt3D TP2
    • 4.7.1
    • Qt3D
    • None
    • qml3d

    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

          Activity

            People

              z35liu Zheng Liu (closed Nokia identity) (Inactive)
              matti.katila Matti Katila
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: