[Interest] Using QWebSocketServer in a thread other than the GUI thread?

Jérôme Godbout jerome at bodycad.com
Wed May 27 16:53:06 CEST 2015


removing parent is essential http://doc.qt.io/qt-5/qobject.html#moveToThread
"The object cannot be moved if it has a parent."
The children will follow to the new thread.

For the reparenting, maybe you can shed some light on it. From what I
understand, moveToThread, make that thread responsible to delete the object
and own him now (the object have the thread affinity to that thread from
now on), why can't you use a parent into that thread then?

Thread#1:

   - ObjA
      - ObjB as child of A


Thread#2:

   - ObjC


Code:
ObjB->setParent(nullptr);
ObjB->moveToThread(Thread2);

Now you have:
Thread#1:

   - ObjA

Thread#2:

   - ObjC
   - ObjB



why inside thread2 set parent of ObjB to ObjC is bad? to get the following:

Thread#2:

   - ObjC
      - ObjB as child of C





On Wed, May 27, 2015 at 10:23 AM, Thiago Macieira <thiago.macieira at intel.com
> wrote:

> On Wednesday 27 May 2015 09:49:06 Jérôme Godbout wrote:
> > Before making the moveToThread(), remove the parent of the object,
> > ->setParent(nullptr);
> > Once moved, you can reparent with object into that Thread.
>
> No, you cannot. The parent must be another object that lives in the current
> thread.
> --
> Thiago Macieira - thiago.macieira (AT) intel.com
>   Software Architect - Intel Open Source Technology Center
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150527/2c15ae3a/attachment.html>


More information about the Interest mailing list