Qt World Summit: Submit your Presentation

Qt3D 2.0 - Scene doesn't update when adding new QEntities

  • I've just started playing with the new Qt3D 2.0, but as documentation is sparse I need a solution to the following.

    I can get a scene to render fine by creating my QEntities and then setting the root on the QAspectEngine. However, any entities that I add after having set the root do not show up in the scene. I'd imagine there would need to be some communication sent to notify that the scene has been updated but I don't know what this would be. Can anyone point me in the right direction on this?

  • Sorry to bump but I can't really progress until I've solved this.

    EDIT: Just discovered something: if a QEntity has its parent entity set in its constructor after having called QAspectEngine::setRootEntity() then it doesn't show up in the scene, but if the parent is set using setParent() then it does show up. This might be a bug with Qt 5.5's implementation of Qt3D.

    To test this, you can copy the code from the "simple-cpp" Qt3D example and put the following at the bottom of main.cpp, between engine.setRootEntity(rootEntity) and view.show():

    // This torus should appear 5 units below the central one.
    Qt3D::QEntity* test = new Qt3D::QEntity(rootEntity);    // Setting the parent here means the torus doesn't show up.
    Qt3D::QTransform* testTransform = new Qt3D::QTransform();
    Qt3D::QTranslateTransform* testTranslate = new Qt3D::QTranslateTransform();
    // This torus should appear 5 units above the central one.
    Qt3D::QEntity* test2 = new Qt3D::QEntity(/*No parent this time*/);
    Qt3D::QTransform* testTransform2 = new Qt3D::QTransform();
    Qt3D::QTranslateTransform* testTranslate2 = new Qt3D::QTranslateTransform();
    test2->setParent(rootEntity);   // Setting the parent here makes the torus show up.

    I'd post an issue on the Qt3D GitHub page but I don't think they allow that right now (or I don't have the permissions).

Log in to reply