简体   繁体   中英

General QThread understanding: quit() and isRunning()

When I execute my thread in Qt with start() I can check if it is running with QThread::isRunning () . It returns true in case the thread is still running. After calling quit() i can quit my thread.

Now my question:

After calling quit() , my isRunning () query should return false , am I right? Equally QThread::isFinished () should return false .

With this question I just want to confirm that i understood one of the main principles of QThread.

I can be wrong, but documentation tells us that quit and exit(int ) finishes thread event loop. But exiting thread event loop doesn't mean that thread is finished. You can even run another qthread without even starting event loop by subclassing and reimplementing run method. So calling quit method doesn't mean that thread isFinished() return true. Just connect yourself to finished() signal and do what you wanted with finished thread.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM