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

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


Before making the moveToThread(), remove the parent of the object,
->setParent(nullptr);
Once moved, you can reparent with object into that Thread.

Note, if using QItem there's also the QQmlEngine that own the item that is
tie to a thread.

On Wed, May 27, 2015 at 3:43 AM, Rainer Wiesenfarth <
Rainer_Wiesenfarth at trimble.com> wrote:

> (Qt 5.3.2 Windows msvc-2010 64bit)
>
> I would like to add a QWebSocketServer to an existing application. I would
> like to have all its operation handled by a thread different from the GUI
> thread to get communication separated from the GUI part.
>
> However, when I use moveToThread with the QWebServerSocket, I get these
> warnings on incoming connections:
>
>   QObject: Cannot create children for a parent that is in a different
>     thread.
>     (Parent is QNativeSocketEngine(0x1b12ab0),
>       parent's thread is QThread( GUI_thread ),
>       current thread is QThread( communication_thread )
>
> In addition, the disconnect event never comes through, probably as a
> consequence of the warning.
>
> Question: Is it possible to use QWebSocketServer in a thread other than
> the GUI thread? How?
>
> Best Regards / Mit freundlichen Grüßen
> Rainer Wiesenfarth
>
> --
> Software Engineer | Trimble Imaging Division
> Rotebühlstraße 81 | 70178 Stuttgart | Germany
> Office +49 711 22881 0 | Fax +49 711 22881 11
> http://www.trimble.com/imaging/ | http://www.inpho.de/
>
> Trimble Germany GmbH, Am Prime Parc 11, 65479 Raunheim
> Eingetragen beim Amtsgericht Darmstadt unter HRB 83893,
> Geschäftsführer: Dr. Frank Heimberg, Hans-Jürgen Gebauer
>
>
> _______________________________________________
> 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/730019b7/attachment.html>


More information about the Interest mailing list