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

Entity created from C++ has missing properties (as seen by JavaScript) wrt Entity created from QML

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.14.1
    • Qt3D
    • None
    • macOS

    Description

      A cuboid entity is created from the following QML:

      Entity {
      id: cuboid0
      components: [
      CuboidMesh

      { xExtent: 1 yExtent: 1 zExtent: 1 }

      ,
      Transform

      { translation.x: -1.5 }

      ,
      PhongMaterial

      { diffuse: Qt.rgba(0.85, 0.85, 1, 1) }

      ,
      ObjectPicker

      { onClicked: selectObject(cuboid0) }

      ]
      }

      Similarily, a cuboid entity is created from C++:

      auto cuboidEntity = new Qt3DCore::QEntity(rootEntity_);
      cuboidEntity->setObjectName("Cuboid");
      auto mat = new Qt3DExtras::QPhongMaterial(cuboidEntity);
      mat->setDiffuse(QColor(217, 217, 255));
      auto t = new Qt3DCore::QTransform(cuboidEntity);
      auto mesh = new Qt3DExtras::QCuboidMesh(cuboidEntity);
      auto picker = new Qt3DRender::QObjectPicker(cuboidEntity);
      connect(picker, &Qt3DRender::QObjectPicker::clicked, [=]

      { emit entityClicked(cuboidEntity); }

      );
      mesh->setXExtent(1);
      mesh->setYExtent(1);
      mesh->setZExtent(1);
      cuboidEntity->addComponent(mat);
      cuboidEntity->addComponent(t);
      cuboidEntity->addComponent(mesh);
      cuboidEntity->addComponent(picker);

      Note: entityClicked signal is connected to selectObject, which does:

      for(var x in e)
      console.log("dump:", x, e[x])

      The result for the entity created from QML is different from the output for the entity created from C++:

      created from QML:

      qml: dump: Qt3DCore::Quick::Quick3DEntity(0x7f9f5d637520)
      qml: dump: objectName
      qml: dump: parent Qt3DCore::Quick::Quick3DEntity(0x7f9f5d62dad0)
      qml: dump: enabled true
      qml: dump: defaultPropertyTrackingMode 0
      qml: dump: propertyTrackingOverrides undefined
      qml: dump: data [object Object]
      qml: dump: childNodes [object Object]
      qml: dump: components [object Object]
      qml: dump: objectNameChanged function()

      { [native code] }
      qml: dump: parentChanged function() { [native code] }

      qml: dump: enabledChanged function()

      { [native code] }
      qml: dump: defaultPropertyTrackingModeChanged function() { [native code] }

      qml: dump: nodeDestroyed function()

      { [native code] }
      qml: dump: setParent function() { [native code] }

      qml: dump: setEnabled function()

      { [native code] }
      qml: dump: setDefaultPropertyTrackingMode function() { [native code] }

      qml: dump: propertyTrackingOverridesChanged function()

      { [native code] }
      QQmlExpression: Expression qrc:/test.qml:44:13 depends on non-NOTIFYable properties:
      Qt3DCore::Quick::Quick3DEntity::data
      Qt3DCore::Quick::Quick3DEntity::data
      Qt3DCore::Quick::Quick3DEntity::childNodes
      Qt3DCore::Quick::Quick3DEntity::childNodes
      Qt3DCore::Quick::Quick3DEntity::components
      Qt3DCore::Quick::Quick3DEntity::components


      created from C++

      qml: dump: Qt3DCore::QEntity(0x7f9f5f7abb60, "Cuboid")
      qml: dump: objectName Cuboid
      qml: dump: parent Qt3DCore::Quick::Quick3DEntity(0x7f9f5d62dad0)
      qml: dump: enabled true
      qml: dump: defaultPropertyTrackingMode 0
      qml: dump: objectNameChanged function() { [native code] }

      qml: dump: parentChanged function()

      { [native code] }
      qml: dump: enabledChanged function() { [native code] }

      qml: dump: defaultPropertyTrackingModeChanged function()

      { [native code] }
      qml: dump: nodeDestroyed function() { [native code] }

      qml: dump: setParent function()

      { [native code] }
      qml: dump: setEnabled function() { [native code] }

      qml: dump: setDefaultPropertyTrackingMode function()

      { [native code] }

      In particular, the entity created from C++ doesn't expose the 'data', 'childNodes', 'components' properties.

      Also, possibly related, is the fact that we get this warning: "QQmlExpression: Expression qrc:/test.qml:44:13 depends on non-NOTIFYable properties" for the exact same 3 properties.

      So it is not possible to inspect scene tree hierarchy and access aspect such as transform from JavaScript?

      Which of the above is the intended behaviour and which is not?

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            seanharmer Sean Harmer
            ff Federico Ferri
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes