[Qt-interest] emit signal from spawned thread

Bo Thorsen bo at fioniasoftware.dk
Sat Aug 20 22:11:02 CEST 2011


Den 19-08-2011 20:37, Guido Seifert skrev:
> Jason, this wasn't the original question. Doing things like that using
> QRunnable or QThread is easy. The question was how to connect to a
> signal, which is emitted in a function, which is passed to
> QtConcurrent::run.
>
> I never looked how QtConcurrent is implemented. According to its docs,
> this function is run within a thread taken from the global
> QTreadPool. Thiago surely has deeper knowledge, I, however, don't see
> a way to get access to this 'unnamed' object from the theadpool to
> make a signal/slot connection.
>
> So it is surely possible to emit signals from such a function, but it
> might be utterly useless.

Oh come on! Just give the runnable a receiver object and let the 
runnable connect it's signal to it. If you don't want to expose your 
receiver directly, use a proxy signal object.

Bo Thorsen,
Fionia Software.

-- 

Expert Qt and C++ developer for hire
Contact me if you need expert Qt help
http://www.fioniasoftware.dk



More information about the Qt-interest-old mailing list