2017-01-21 18:16:57 +01:00
|
|
|
|
#ifndef STOPWATCH_H
|
|
|
|
|
|
#define STOPWATCH_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <QTimer>
|
|
|
|
|
|
#include <QElapsedTimer>
|
2017-01-22 08:50:41 +01:00
|
|
|
|
|
|
|
|
|
|
class QLabel;
|
2017-01-21 18:16:57 +01:00
|
|
|
|
|
|
|
|
|
|
class StopWatch : public QObject {
|
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
public:
|
|
|
|
|
|
StopWatch();
|
|
|
|
|
|
|
|
|
|
|
|
void start();
|
|
|
|
|
|
qint64 elapsed();
|
2017-01-22 08:50:41 +01:00
|
|
|
|
void stop();
|
|
|
|
|
|
|
|
|
|
|
|
void setOutputLabel(QLabel *label);
|
2017-01-21 18:16:57 +01:00
|
|
|
|
private:
|
2017-01-22 08:50:41 +01:00
|
|
|
|
QElapsedTimer m_elapsed; // = nullptr; ///< Keeps time
|
|
|
|
|
|
QTimer m_timer; ///< triggers updates
|
|
|
|
|
|
QLabel* m_output = nullptr;
|
|
|
|
|
|
qint64 m_timeTaken = 0LL;
|
2017-01-21 18:16:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
|
void updateTimer();
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // STOPWATCH_H
|