Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4738a3b
commit 08c565c
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#ifndef STRINGCHANGEWATCHER_H | ||
#define STRINGCHANGEWATCHER_H | ||
|
||
#include <QObject> | ||
|
||
class stringChangeWatcher : public QObject | ||
{ | ||
Q_OBJECT | ||
Q_PROPERTY( QString value READ getValue WRITE setValue NOTIFY valueChanged ) | ||
public: | ||
explicit stringChangeWatcher( QObject* parent = nullptr ) : | ||
QObject{ parent }, str{ "" } {} | ||
virtual ~stringChangeWatcher() {} | ||
|
||
QString getValue() const { return str; } | ||
public slots: | ||
void setValue( QString value ) | ||
{ | ||
if ( value != str ) { | ||
str = value; | ||
emit valueChanged( str ); | ||
} | ||
} | ||
signals: | ||
void valueChanged( QString value ); | ||
private: | ||
QString str; | ||
|
||
}; | ||
#endif // STRINGCHANGEWATCHER_H |