【发布时间】:2016-03-26 18:56:18
【问题描述】:
我有一个简单的QObject:
class Engine : public QObject
{
Q_OBJECT
public:
explicit Engine(QObject* parent = 0);
signals:
void finished();
public slots:
void start();
};
实例Engine* engine 存储在主窗口类中。当按下按钮时,会发生以下情况:
QThread* thread = new QThread;
engine->moveToThread(thread);
connect(engine, SIGNAL(error(QString)), this, SLOT(errorString(QString)));
connect(thread, SIGNAL(started()), engine, SLOT(start()));
connect(engine, SIGNAL(finished()), thread, SLOT(quit()));
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
thread->start();
我的问题是,在thread 完成后,engine 会发生什么?我可以创建另一个线程并将engine 移动到该线程,然后再重复一遍吗?
【问题讨论】:
标签: c++ multithreading qt qthread