I don't have a forever loop like this question, but it still doesn't emit the finished() signal,
In the constructor of a class:
connect (&thread, SIGNAL(started()), SLOT(threadFunc()));
connect (&thread, SIGNAL(finished()), SLOT(finished()));
In the finished() function,
void XX::finished()
{
qDebug() << "Completed";
}
void XX::threadFunc()
{
qDebug() << "Thread finished"; // only single line, finishes immediately
}
But I never see the finished()
get called, everytime before I start the thread with thread.start()
, I must call thread.terminate()
manually, did I misunderstood the usage of QThread?