34 lines
449 B
C++
34 lines
449 B
C++
|
|
#pragma once
|
|
|
|
#include <QObject>
|
|
#include <QTimer>
|
|
|
|
class TimerComponent : public QObject {
|
|
|
|
Q_OBJECT
|
|
Q_PROPERTY(int seconds READ seconds NOTIFY secondsChanged)
|
|
|
|
public:
|
|
|
|
explicit TimerComponent(QObject* parent = nullptr);
|
|
|
|
int seconds() const { return seconds_; }
|
|
|
|
public slots:
|
|
|
|
void reset();
|
|
|
|
signals:
|
|
|
|
void secondsChanged();
|
|
|
|
private:
|
|
|
|
void increment();
|
|
|
|
int seconds_ = 0;
|
|
QTimer timer_;
|
|
|
|
};
|