-
Notifications
You must be signed in to change notification settings - Fork 0
/
elapsedtimer.h
47 lines (36 loc) · 1 KB
/
elapsedtimer.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
#ifndef ELAPSEDTIMER_H
#define ELAPSEDTIMER_H
#include <QTimer>
#include <QObject>
#include <QElapsedTimer>
#include <QTime>
class ElapsedTimer : public QObject
{
Q_OBJECT
Q_PROPERTY(QTime elapsed READ elapsed NOTIFY elapsedChanged)
Q_PROPERTY(bool running READ running WRITE setRunning NOTIFY runningChanged)
Q_PROPERTY(int interval READ interval WRITE setInterval NOTIFY intervalChanged)
qint64 t_elapsed = 0;
int m_interval = 100;
int tid = -1;
bool m_running = false;
QElapsedTimer t;
public:
explicit ElapsedTimer(QObject *parent = 0);
QTime elapsed() const;
inline bool running() const { return m_running; }
void setRunning(bool running);
int interval() const;
void setInterval(int interval);
signals:
void elapsedChanged();
void runningChanged(bool running);
void intervalChanged(int interval);
public slots:
void start();
void pause();
void reset();
protected:
void timerEvent(QTimerEvent *e);
};
#endif // ELAPSEDTIMER_H