1.定义自己的线程类
MyThread.h
#include <QThread>
class MyThread : public QThread
{
public:
void run();
};
MyThread.cpp
#include "MyThread.h"
void MyThread::run()
{
}
2.使用线程类
包含头文件:
#include "MyThread.h"
生成线程对象并启动
MyThread thread;
thread.start();