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 14:01:08 +0100 |
commit | a919ae95d98c6210675e24d6ca683bc60f51d884 (patch) | |
tree | b7a96480298642172089c2721ad24ca1ec4c7550 /examples/qml/referenceexamples/binding/birthdayparty.h | |
parent | f0511bef9386e33e00ad102b6b955a5b5d7aa4fb (diff) |
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
Change-Id: Iebce1b810ce00f29395207d93303363b3b71e52e
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
(cherry picked from commit c442ed4d65b0319e4abd7a931cfb2f1f72842b84)
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'examples/qml/referenceexamples/binding/birthdayparty.h')
-rw-r--r-- | examples/qml/referenceexamples/binding/birthdayparty.h | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/examples/qml/referenceexamples/binding/birthdayparty.h b/examples/qml/referenceexamples/binding/birthdayparty.h index 846a016cfc..2881dfead2 100644 --- a/examples/qml/referenceexamples/binding/birthdayparty.h +++ b/examples/qml/referenceexamples/binding/birthdayparty.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 BIRTHDAYPARTY_H #define BIRTHDAYPARTY_H @@ -62,7 +63,7 @@ class BirthdayPartyAttached : public QObject Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp NOTIFY rsvpChanged) QML_ANONYMOUS public: - BirthdayPartyAttached(QObject *object); + using QObject::QObject; QDate rsvp() const; void setRsvp(QDate); @@ -86,14 +87,14 @@ class BirthdayParty : public QObject QML_ELEMENT QML_ATTACHED(BirthdayPartyAttached) public: - BirthdayParty(QObject *parent = nullptr); + using QObject::QObject; Person *host() const; void setHost(Person *); QQmlListProperty<Person> guests(); - int guestCount() const; - Person *guest(int) const; + qsizetype guestCount() const; + Person *guest(qsizetype) const; QString announcement() const; void setAnnouncement(const QString &); @@ -106,7 +107,7 @@ signals: void hostChanged(); private: - Person *m_host; + Person *m_host = nullptr; QList<Person *> m_guests; }; |