-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrealqthread.h
66 lines (63 loc) · 1.47 KB
/
realqthread.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef REALQTHREAD_H
#define REALQTHREAD_H
#include <QObject>
#include <QWidget>
#include <QThread>
#include <QProgressBar>
#include "corekernel.h"
#include <QMutexLocker>
#define MAXCMP 8
class RealQThread : public QThread
{
Q_OBJECT
public:
explicit RealQThread(QObject *parent = 0)
: QThread(parent),
m_bStopped(false)
{
qDebug() << "Handle Thread : " << QThread::currentThreadId();
}
~RealQThread()
{
quit();
wait();
}
void begin();
void stop()
{
QMutexLocker locker(&m_mutex);
m_bStopped = true;
wait();
}
int started;
void set_dw(Drawabler *dw) {
this->dw2 = dw;
}
QSqlDatabase db;
QProgressBar *qpb;
QMySQlQueryModel *DataModel;
protected:
virtual void run() Q_DECL_OVERRIDE {
for(int mode = 0;mode < 4; mode ++) {
msleep(500);
dw2->FindBest(mode);
QMutexLocker locker(&m_mutex);
if (m_bStopped)
break;
}
emit signalRunOver();
}
signals:
void resultReady(int value);
void signalRunOver();
private slots:
void getdw(Drawabler *dw);
void giveresult(int val) {
emit resultReady(val);
}
private:
bool m_bStopped;
QMutex m_mutex;
Drawabler *dw2;
};
#endif // REALQTHREAD_H