Talk:QThreads general usage

From Qt Wiki
Revision as of 09:30, 13 June 2024 by Srce (talk | contribs) (Add some discussion)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Should:

connect(worker, &Worker::finished, thread, &QThread::quit);

Actually be:

connect(worker, &Worker::finished, thread, &QThread::quit, Qt::DirectConnection);

See: https://forum.qt.io/topic/114371/qthread-does-not-quit-why/7


Would also be useful if there was an example of the recommended way to indicate a worker should terminate from another thread? Eg: QThread::requestInterruption() and QThread::currentThread()->isInterruptionRequested() (If that is appropriate)

And also perhaps show how QCoreApplication::processEvents(); can be used in a worker thread for slot handling.