以前看过在linux下C编程的线程书籍,今天来看看Qt如何启动一个线程吧,代码就以精通Qt4编程的为例
先来给出每个文件的相关代码然后再加以分析
//*************dialog.h**************//
#ifndef DIALOG_H
#define DIALOG_H
#include <QDialog>
#define MAXSIZE 5 //最大的线程数
class QDialogButtonBox;
class QProgressBar;
class QPushButton;
class WorkThread;
class ThreadDlg : public QDialog
{
Q_OBJECT
public:
ThreadDlg(QWidget *parent = 0);
public slots:
void start();
void stop();
private:
QPushButton *startButton;
QPushButton *quitButton;
QPushButton *stopButton;
QDialogButtonBox *buttonBox;
WorkThread* threadVector[MAXSIZE];
};
#endif
//***********end end end************//
//***********mainwindow.h************//