class myThread:public QThread
{
Q_OBJECT
public:
explicit myThread();
void run();//执行线程功能的虚函数
void my_start(){
this->start();//启动线程
}
};
void myThread::run(){
for(int i=0;i<5;i++){//每隔100ms打印一句
QThread::msleep(100);
qDebug()<<"thread running";
}
}
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
myThread mt;
mt.my_start();
qDebug()<<"thread start";
return a.exec();
}
