Query related to threads in Qt
I want my application to wait indefinitely until a task g开发者_如何学运维ets completed in another thread.
How do I perform this in Qt?
On windows, we use waitforsingletonobject
, but is there any alternative to this?
Waiting for threads to finish certain tasks (thread synchronization) is the job of the QWaitCondition class.
Call wait on your QThread
object.
Use QtConcurrent::run. See my answer to this question. Note that the QFutureWatcher API can work in blocking (the waitForFinished
method) and non-blocking (the finished
signal) modes.
精彩评论