创建一个类继承自QObject:
Class Thread03 : public QObject
声明槽函数和线程:
public slots:void fun();private:QThread m_th;
在构造函数中:
Thread03::Thread03()
{this->moveToThread(&m_th);m_th.start();qDebug() << "Thread03 construct " << QThread::currentThreadId();
}
参考:Qt -- 线程的使用(基础到高级) - 知乎