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

Elvis Stansvik elvstone at gmail.com
Wed May 27 11:48:29 CEST 2015


2015-05-27 9:43 GMT+02:00 Rainer Wiesenfarth <Rainer_Wiesenfarth at trimble.com
>:

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

I think the real question is why you would want to do that. Unless you're
handling an insane amount of traffic, the communication is not going to be
a bottle neck that affects GUI interaction in a negative way. I think you
better keep your QWebSocketServer in your main thread. If you need to do
CPU intensive processing of the messages, I think it is better you off-load
the actual processing to separate threads.

Elvis



>
> 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/a3b5a1ab/attachment.html>


More information about the Interest mailing list