[Interest] Emitting a signal from a different thread than the object lives in

Etienne Sandré-Chardonnal etienne.sandre at m4x.org
Fri Aug 26 10:33:33 CEST 2016


Hi,

I have an object which subclasses QThread for performing an asynchronous
operation. Before any objection rises about that, I know that for most uses
QThread subclassing is not the way to go, and creating an object which is
pushed to a regular QThread is better, and I'm doing it 99% of the time,
but here it was more straightforward to simply subclass QThread and
overload run(), and no event loop is needed. This works fine.

Now I would like the run() function to make the QThread subclass emit
signals. If I just do "emit mySignal()" inside run(), my guess is this will
not work unless there is a special mechanism handling this.

Can I do this, or do I need a full event loop, an object living inside the
QThread, and a queued connection between signals? (ie the regular QThread
use)

Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160826/fe4cfde3/attachment.html>


More information about the Interest mailing list