[Interest] QThreads: There's no one way to "do it right"! :)
Mandeep Sandhu
mandeepsandhu.chd at gmail.com
Wed Jan 23 08:42:21 CET 2013
First I thought "I was doing it right"
Then they said "you're doing it wrong"
(http://blog.qt.digia.com/blog/2010/06/17/youre-doing-it-wrong/)
Then I thought "I _finally_ got it right"!!
Now they say "You were not doing so wrong"
(http://woboq.com/blog/qthread-you-were-not-doing-so-wrong.html)!! :D
End of my Cute poem! :P
Jokes apart, which method do most ppl here prefer when doing threading?
Clearly, if done carefully, both methods work as intented.
My rule of thumb is that, if you're doing a simple but compute
intensive task where you don't want communication via signal/slots
(probably thats what the author of the last post meant by not needing
event loop), go with subclassing QThread.
However, if your worker is a little more complex, where you need to
maintain state across runs, do signal/slot comm etc, then it's better
to go with a 'moveToThread()' approach.
Regards,
-mandeep
More information about the Interest
mailing list