Hi, this problem might sound weird, but it got me crazy:mad: as I just started using QThread. Here is a short program to test using QThread.
Code:
#include <QThread> #include <QCoreApplication> #include <QDebug> int main (int argc, char** argv) { QThread t; t.start(); if (t.isRunning()) qDebug() << "thread is started"; //t.exit(); //t.quit(); t.terminate(); qDebug() << "try to stop thread"; if(!t.isRunning()) qDebug() << "thread is stopped"; return app.exec(); }
I tried exit(), quit() and terminate() and waited for a long time.
The expected "thread is stopped" never ever shows up (no matter how long I waited). The thread is like running forever. Could anyone help me with this and show me how to properly stop a QThread?
Thank you.
Ves