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

Thiago Macieira thiago.macieira at intel.com
Wed May 27 17:35:58 CEST 2015


On Wednesday 27 May 2015 10:53:06 Jérôme Godbout wrote:
> 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?

You can use a parent that lives in that thread. The problem is that you 
suggested parenting back to the thread object, which doesn't have affinity to 
the thread it started.

> > 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




More information about the Interest mailing list