Talk:QThreads general usage

From Qt Wiki
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.