[Qt-interest] emit signal from spawned thread
Guido Seifert
wargand at gmx.de
Fri Aug 19 16:35:50 CEST 2011
> That seems kind of silly to me. I can understand not making any kind of
> automatic connections, but you should be able to emit your own signals.
It is not silly, it is just a totally different use case. You have a
function, which takes a long time to complete and returns a value.
You just want to call this function in a non-blocking way and get a
notification when the value is available. That's when you use QtConcurrent::run.
For the signal/slot mechanism you need an object, which emits a signal, and an
object, which receives it. With QtConcurrent::run there is no non-hack way to
get the sending object. It is just not necessary for what
QtConcurrent::run is designed.
> I guess the alternative is to put the method in a QThread object?
This will work for sure. QRunnable might also be a good alternative.
Guido
More information about the Qt-interest-old
mailing list