Currently I am trying to import a scene in my Qt3d application. The problem
is, when creating an instance from QSceneLoader and set the sources QUrl
then add it to an Entity, it freezes the application until it finishes the
importing. I tried to put it in thread like :

void start(){
    qDebug() << "Thread";

    QAspectEngine* pAs = new QAspectEngine();
    pAs->registerAspect(new QRenderAspect());

    QRenderSettings *renderSettings = new QRenderSettings();
    renderSettings->setActiveFrameGraph(new Qt3DExtras::QForwardRenderer());

   // Root entity
   Qt3DCore::QEntity *sceneRoot2 = new Qt3DCore::QEntity();
   sceneRoot2->addComponent(renderSettings);

   pAs->setRootEntity(QSharedPointer<QEntity>(sceneRoot2));

   Qt3DRender::QSceneLoader *sceneLoader = new Qt3DRender::QSceneLoader();
   SceneWalker sceneWalker(sceneLoader);
   QObject::connect(sceneLoader,
&Qt3DRender::QSceneLoader::statusChanged, &sceneWalker,
&SceneWalker::onStatusChanged);

   
sceneLoader->setSource(QUrl::fromLocalFile("C:/Users/USER/Downloads/TreeTest.obj"));
   sceneRoot2->addComponent(sceneLoader);

}

This fuction will run when the Qthread emit the started signal, but then i
got this : QObject::setParent: Cannot set parent, new parent is in a
different thread.

So i do not know how to import a scene in qt3d without freezing the app,
can any one help please.
Thanks in advance.
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to