From c442ed4d65b0319e4abd7a931cfb2f1f72842b84 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 2 Nov 2021 09:04:21 +0100 Subject: 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 Reviewed-by: Ulf Hermann --- examples/qml/referenceexamples/methods/birthdayparty.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'examples/qml/referenceexamples/methods/birthdayparty.h') diff --git a/examples/qml/referenceexamples/methods/birthdayparty.h b/examples/qml/referenceexamples/methods/birthdayparty.h index 5c2f3c9def..b43308ac8f 100644 --- a/examples/qml/referenceexamples/methods/birthdayparty.h +++ b/examples/qml/referenceexamples/methods/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 @@ -61,21 +62,21 @@ class BirthdayParty : public QObject Q_PROPERTY(QQmlListProperty guests READ guests) QML_ELEMENT public: - BirthdayParty(QObject *parent = nullptr); + using QObject::QObject; Person *host() const; void setHost(Person *); QQmlListProperty guests(); - int guestCount() const; - Person *guest(int) const; + qsizetype guestCount() const; + Person *guest(qsizetype) const; // ![0] Q_INVOKABLE void invite(const QString &name); // ![0] private: - Person *m_host; + Person *m_host = nullptr; QList m_guests; }; -- cgit v1.2.3