Talk:QThreads general usage: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
(Add some discussion)
 
(No difference)

Latest revision as of 09:30, 13 June 2024

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.