[Qt-interest] QThread: infinite loops
Andre Somers
andre at familiesomers.nl
Fri Feb 25 07:22:44 CET 2011
Op 25-2-2011 4:51, Jason H schreef:
> To clarify, QThread gives you a default run() that does "nothing". Maybe it
> should have been a pure virtual, but I do believe the "nothing" that it does
> does include its own event loop.
>
In Qt 4.3, run() _was_ pure virtual. From 4.4 onwards, the method gained
a default implementation: calling exec(). With this, also the
recommended way of using QThread changed. While you still _can_ use
QThread by reimplementing run(), many people make mistakes doing so. So,
the now recommended way to use QThread is to use it as-is, and simply
move a QObject to the created thread.
André
More information about the Qt-interest-old
mailing list