我在QThread類中的信號/插槽存在問題。我的設計如下所示:帶線程的Qt信號插槽
class Manager : public QObject {
Q_OBJECT
public:
Manager(QObject* parent) : QObject(parent) {
Thread thread* = new Thread(this);
connect(this, SIGNAL(testsignal()), thread, SLOT(test()));
thread->start();
...
emit testsignal();
}
signals:
void testsignal();
};
class Thread : public QThread {
Q_OBJECT
public slots:
void test() {
qDebug() << "TEST";
}
private:
void run() {}
};
信號永遠達不到我的test()方法。有人可以幫忙嗎?謝謝。
'主題::測試()'不被定義爲一個槽。 – owacoder
對不起。這是一個錯字。 – adapto
'線程線程*'另一個錯字?你的代碼現在適用於我。 – SingerOfTheFall