diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-11-02 09:04:21 +0100 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-11-04 10:51:39 +0100 |
| commit | c442ed4d65b0319e4abd7a931cfb2f1f72842b84 (patch) | |
| tree | 99009060ae1c23ee98bef51f213926cd961f468a /examples/qml/referenceexamples/binding/person.h | |
| parent | 33b16814c90fb4b70043be4f65fbbf783aee5d86 (diff) | |
| download | qtdeclarative-c442ed4d65b0319e4abd7a931cfb2f1f72842b84.tar.gz | |
Polish the QML reference examples
- Use member initialization, which allows for using
constructors from the base classes
- Use qsizetype for indexes
- Use qInfo() instead of qWarning() for printing
- Add spaces/fix formatting
Pick-to: 6.2
Change-Id: Iebce1b810ce00f29395207d93303363b3b71e52e
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'examples/qml/referenceexamples/binding/person.h')
| -rw-r--r-- | examples/qml/referenceexamples/binding/person.h | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/examples/qml/referenceexamples/binding/person.h b/examples/qml/referenceexamples/binding/person.h index af9864950a..e84075bb36 100644 --- a/examples/qml/referenceexamples/binding/person.h +++ b/examples/qml/referenceexamples/binding/person.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -47,6 +47,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + #ifndef PERSON_H #define PERSON_H @@ -63,7 +64,7 @@ class ShoeDescription : public QObject Q_PROPERTY(qreal price READ price WRITE setPrice NOTIFY shoeChanged) QML_ANONYMOUS public: - ShoeDescription(QObject *parent = nullptr); + using QObject::QObject; int size() const; void setSize(int); @@ -76,14 +77,15 @@ public: qreal price() const; void setPrice(qreal); + signals: void shoeChanged(); private: - int m_size; + int m_size = 0; QColor m_color; QString m_brand; - qreal m_price; + qreal m_price = 0; }; class Person : public QObject @@ -95,12 +97,13 @@ class Person : public QObject // ![0] QML_ANONYMOUS public: - Person(QObject *parent = nullptr); + using QObject::QObject; QString name() const; void setName(const QString &); ShoeDescription *shoe(); + signals: void nameChanged(); @@ -114,7 +117,7 @@ class Boy : public Person Q_OBJECT QML_ELEMENT public: - Boy(QObject * parent = nullptr); + using Person::Person; }; class Girl : public Person @@ -122,7 +125,7 @@ class Girl : public Person Q_OBJECT QML_ELEMENT public: - Girl(QObject * parent = nullptr); + using Person::Person; }; #endif // PERSON_H |
