Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // textobject.h
- #ifndef TEXTOBJECT_H
- #define TEXTOBJECT_H
- #include <QDebug>
- class TextObject: public QObject
- {
- Q_OBJECT
- QString m_text;
- public:
- TextObject() : m_text("initial")
- {
- qDebug() << "TextObject" << m_text << this;
- connect(this, SIGNAL(textChanged(QString)), this, SLOT(CPP_SLOT_textChanged()));
- }
- Q_PROPERTY(QString text READ getText WRITE setText NOTIFY textChanged)
- QString getText() const
- {
- qDebug() << "getText" << m_text;
- return m_text;
- }
- signals:
- void textChanged(QString text);
- public slots:
- void setText(QString text)
- {
- if (m_text == text)
- {
- qDebug() << "setText" << m_text << "UNCHANGED";
- return;
- }
- qDebug() << "setText" << m_text << "=" << text;
- m_text = text;
- emit textChanged(text);
- }
- void CPP_SLOT_textChanged()
- {
- qDebug() << "CPP_SLOT_textChanged" << m_text;
- }
- void changeTextViaCPP(QString text)
- {
- qDebug() << "changeTextViaCPP" << m_text << "=" << text;
- setText(text);
- }
- };
- #endif // TEXTOBJECT_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement