[Interest] [Qt3D][Threads] A right way to do calculations for qt 3d entities in separate thread
Sean Harmer
sh at theharmers.co.uk
Sat Apr 15 13:03:11 CEST 2017
Hi,
On 15/04/2017 11:45, Oleg Evseev wrote:
> Hi,
>
> I have a Scene3D with different QEntities.
>
> One of the entity have a slot with calculations which involves updating
> QGeometry of one of its child (QEntity) and sometimes creating new child
> entity.
> I'm looking for a way to move those calculations into separate thread.
>
> But according to http://doc.qt.io/qt-5/threads-qobject.html the first
> constraint to be aware of is "The child of a QObject must always be
> created in the thread where the parent was created".
>
> So the only thing that comes to mind is to use signals from separate
> thread to main one where is parent entity as the request to create new
> child entity and another signal from main thread to separate with
> pointer of new created child.
> Is this a right way to do it?
We do something analogous with the sceneparser plugins which for the
scene file being loaded, it creates a QEntity subtree complete with
GeometryRenderer, Material, Transform components. These are then moved
to the main thread with QObject::moveToThread and grafted into the main
tree with QNode::setParent(placeToGraftThisSubTreeIn).
Hope this helps,
Sean
>
> Thanks in advance for help.
>
> ---
> With regards, Oleg
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
More information about the Interest
mailing list