qml demo
This commit is contained in:
33
src/TimerComponent.hpp
Normal file
33
src/TimerComponent.hpp
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
#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_;
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user