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

Qt3D Warning: Created graphical object was not placed in the graphics scene

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.7.3
    • Qt3D
    • None
    • Windows

    Description

      Import of Qt3D.Core (Although unused) results with warning (QML QtObject: Created graphical object was not placed in the graphics scene) in the following code:

      import QtQuick
      
      // as soon as this import is added, warnings appear
      import Qt3D.Core as Unused
      
      Window {
          width: 640
          height: 480
          visible: true
      
          // if 'target' and 'child' are Items no warning appears
          // if at least one is a QtObject a warning does appear
          Item {
              id: target
          }
      
          Component {
              id: child
      
              QtObject {}
          }
      
          Component.onCompleted: {
              child.createObject(target);
          }
      } 

      The reason for this problem is probably that on loading of Qt3D Core plugin the following code is run:

      QQmlPrivate::RegisterAutoParent autoparent = { 0, &qquick3ditem_autoParent };
      QQmlPrivate::qmlregister(QQmlPrivate::AutoParentRegistration, &autoparent); 

      The following fix should fix the problem:

      static QQmlPrivate::AutoParentResult qquick3ditem_autoParent(QObject *obj, QObject *parent)
      {
          auto parentNode = qmlobject_cast<Qt3DCore::QNode *>(parent);
          if (parentNode) {
              auto node = qmlobject_cast<Qt3DCore::QNode *>(obj);
              if (node) {
                  // A QNode has another QNode child
                  node->setParent(parentNode);
                  return QQmlPrivate::Parented;
              }
          // FIX: the following line should be
          // } else if (qmlobject_cast<Qt3DCore::QNode *>(obj)) {
          } else {
              return QQmlPrivate::IncompatibleParent;
          }
          return QQmlPrivate::IncompatibleObject;
      } 

      Compare qt3d (invalid): https://github.com/qt/qt3d/blob/6.7.3/src/quick3d/quick3d/qt3dquick_global.cpp
      and same function for quick3d (ok): https://github.com/qt/qtquick3d/blob/6.7.3/src/quick3d/plugin.cpp

       

      Attachments

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

        Activity

          People

            seanharmer Sean Harmer
            permotion88 Karol Polak
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes