1
我没有一个永远的循环like this question,但它仍然没有发出成品()信号,QThread :: finished()永远不会被发射?
在类的构造函数:
connect (&thread, SIGNAL(started()), SLOT(threadFunc()));
connect (&thread, SIGNAL(finished()), SLOT(finished()));
在成品()函数,
void XX::finished()
{
qDebug() << "Completed";
}
void XX::threadFunc()
{
qDebug() << "Thread finished"; // only single line, finishes immediately
}
但我从来没有看到finished()
被调用,每次开始之前,我与thread.start()
线程,我必须手动调用thread.terminate()
,做我误解的QThread的使用情况如何?
嗯,我没有继承QThread,只是使用它的信号 – daisy
@ warl0ck所以它意味着你的线程有默认的实现并等待exit,正如我上面所说的。 – fasked