From a919ae95d98c6210675e24d6ca683bc60f51d884 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 Change-Id: Iebce1b810ce00f29395207d93303363b3b71e52e Reviewed-by: Cristian Maureira-Fredes Reviewed-by: Ulf Hermann (cherry picked from commit c442ed4d65b0319e4abd7a931cfb2f1f72842b84) Reviewed-by: Fabian Kosmale --- examples/qml/referenceexamples/methods/birthdayparty.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'examples/qml/referenceexamples/methods/birthdayparty.cpp') diff --git a/examples/qml/referenceexamples/methods/birthdayparty.cpp b/examples/qml/referenceexamples/methods/birthdayparty.cpp index 4b30d31aeb..1308a09b72 100644 --- a/examples/qml/referenceexamples/methods/birthdayparty.cpp +++ b/examples/qml/referenceexamples/methods/birthdayparty.cpp @@ -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,12 +47,8 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include "birthdayparty.h" -BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_host(nullptr) -{ -} +#include "birthdayparty.h" // ![0] Person *BirthdayParty::host() const @@ -70,12 +66,12 @@ QQmlListProperty BirthdayParty::guests() return {this, &m_guests}; } -int BirthdayParty::guestCount() const +qsizetype BirthdayParty::guestCount() const { return m_guests.count(); } -Person *BirthdayParty::guest(int index) const +Person *BirthdayParty::guest(qsizetype index) const { return m_guests.at(index); } -- cgit v1.2.3