#include "mythread.h"
Mythread::Mythread(QObject *parent) :
QThread(parent)
{
//初始化一般在构造函数中进行赋值
this->num=0;
}
void Mythread::run()
{
while(1)
{
emit wxy(this->num);
this->num++;
usleep (800*1000);
}
}
#ifndef MYTHREAD_H
#define MYTHREAD_H
#include
class Mythread : public QThread
{
Q_OBJECT
public:
explicit Mythread(QObject *parent = 0);
signals:
void wxy(int num); //自定义一个信号,每隔一段时间就发出去给MainWindow
public slots:
protected:
void run();
private:
int num();
};
#endif // MYTHREAD_H