diff options
Diffstat (limited to 'examples/qml/referenceexamples/grouped')
-rw-r--r-- | examples/qml/referenceexamples/grouped/CMakeLists.txt | 44 | ||||
-rw-r--r-- | examples/qml/referenceexamples/grouped/birthdayparty.cpp | 29 | ||||
-rw-r--r-- | examples/qml/referenceexamples/grouped/birthdayparty.h | 34 | ||||
-rw-r--r-- | examples/qml/referenceexamples/grouped/example.qml | 41 | ||||
-rw-r--r-- | examples/qml/referenceexamples/grouped/grouped.pro | 15 | ||||
-rw-r--r-- | examples/qml/referenceexamples/grouped/grouped.qrc | 5 | ||||
-rw-r--r-- | examples/qml/referenceexamples/grouped/main.cpp | 42 | ||||
-rw-r--r-- | examples/qml/referenceexamples/grouped/person.cpp | 59 | ||||
-rw-r--r-- | examples/qml/referenceexamples/grouped/person.h | 77 |
9 files changed, 0 insertions, 346 deletions
diff --git a/examples/qml/referenceexamples/grouped/CMakeLists.txt b/examples/qml/referenceexamples/grouped/CMakeLists.txt deleted file mode 100644 index b1c7587b58..0000000000 --- a/examples/qml/referenceexamples/grouped/CMakeLists.txt +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright (C) 2022 The Qt Company Ltd. -# SPDX-License-Identifier: BSD-3-Clause - -cmake_minimum_required(VERSION 3.16) -project(grouped LANGUAGES CXX) - -set(CMAKE_AUTOMOC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/qml/referenceexamples/grouped") - -find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml) - -qt_add_executable(grouped - birthdayparty.cpp birthdayparty.h - main.cpp - person.cpp person.h -) - -set_target_properties(grouped PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) - -target_link_libraries(grouped PUBLIC - Qt::Core - Qt::Gui - Qt::Qml -) - -qt_add_qml_module(grouped - URI People - QML_FILES example.qml - NO_RESOURCE_TARGET_PATH -) - -install(TARGETS grouped - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/qml/referenceexamples/grouped/birthdayparty.cpp b/examples/qml/referenceexamples/grouped/birthdayparty.cpp deleted file mode 100644 index 6cf8a608e7..0000000000 --- a/examples/qml/referenceexamples/grouped/birthdayparty.cpp +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#include "birthdayparty.h" - -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QQmlListProperty<Person> BirthdayParty::guests() -{ - return {this, &m_guests}; -} - -qsizetype BirthdayParty::guestCount() const -{ - return m_guests.count(); -} - -Person *BirthdayParty::guest(qsizetype index) const -{ - return m_guests.at(index); -} diff --git a/examples/qml/referenceexamples/grouped/birthdayparty.h b/examples/qml/referenceexamples/grouped/birthdayparty.h deleted file mode 100644 index 7f011ca95f..0000000000 --- a/examples/qml/referenceexamples/grouped/birthdayparty.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#ifndef BIRTHDAYPARTY_H -#define BIRTHDAYPARTY_H - -#include <QObject> -#include <QQmlListProperty> -#include "person.h" - -class BirthdayParty : public QObject -{ - Q_OBJECT - Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QQmlListProperty<Person> guests READ guests) - Q_CLASSINFO("DefaultProperty", "guests") - QML_ELEMENT -public: - using QObject::QObject; - - Person *host() const; - void setHost(Person *); - - QQmlListProperty<Person> guests(); - qsizetype guestCount() const; - Person *guest(qsizetype) const; - -private: - Person *m_host; - QList<Person *> m_guests; -}; - - -#endif // BIRTHDAYPARTY_H diff --git a/examples/qml/referenceexamples/grouped/example.qml b/examples/qml/referenceexamples/grouped/example.qml deleted file mode 100644 index 31d122e647..0000000000 --- a/examples/qml/referenceexamples/grouped/example.qml +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -import People -import QtQuick // For QColor - -// ![0] -BirthdayParty { - host: Boy { - name: "Bob Jones" - shoe { size: 12; color: "white"; brand: "Bikey"; price: 90.0 } - } - - Boy { - name: "Leo Hodges" -//![grouped] - shoe { size: 10; color: "black"; brand: "Thebok"; price: 59.95 } -//![grouped] - } - // ![1] - Boy { - name: "Jack Smith" - shoe { - size: 8 - color: "blue" - brand: "Luma" - price: 19.95 - } - } - // ![1] - Girl { - name: "Anne Brown" -//![ungrouped] - shoe.size: 7 - shoe.color: "red" - shoe.brand: "Job Macobs" - shoe.price: 699.99 -//![ungrouped] - } -} -// ![0] diff --git a/examples/qml/referenceexamples/grouped/grouped.pro b/examples/qml/referenceexamples/grouped/grouped.pro deleted file mode 100644 index 1513ac552d..0000000000 --- a/examples/qml/referenceexamples/grouped/grouped.pro +++ /dev/null @@ -1,15 +0,0 @@ -QT += qml - -CONFIG += qmltypes -QML_IMPORT_NAME = People -QML_IMPORT_MAJOR_VERSION = 1 - -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp -HEADERS += person.h \ - birthdayparty.h -RESOURCES += grouped.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/qml/referenceexamples/grouped -INSTALLS += target diff --git a/examples/qml/referenceexamples/grouped/grouped.qrc b/examples/qml/referenceexamples/grouped/grouped.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/qml/referenceexamples/grouped/grouped.qrc +++ /dev/null @@ -1,5 +0,0 @@ -<!DOCTYPE RCC><RCC version="1.0"> -<qresource> - <file>example.qml</file> -</qresource> -</RCC> diff --git a/examples/qml/referenceexamples/grouped/main.cpp b/examples/qml/referenceexamples/grouped/main.cpp deleted file mode 100644 index 16f17262a2..0000000000 --- a/examples/qml/referenceexamples/grouped/main.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -#include <QCoreApplication> -#include <QQmlEngine> -#include <QQmlComponent> -#include <QDebug> -#include "birthdayparty.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - - QQmlEngine engine; - QQmlComponent component(&engine, QUrl("qrc:example.qml")); - auto *party = qobject_cast<BirthdayParty *>(component.create()); - - if (party && party->host()) { - qInfo() << party->host()->name() << "is having a birthday!"; - - if (qobject_cast<Boy *>(party->host())) - qInfo() << "He is inviting:"; - else - qInfo() << "She is inviting:"; - - Person *bestShoe = nullptr; - for (qsizetype ii = 0; ii < party->guestCount(); ++ii) { - Person *guest = party->guest(ii); - qInfo() << " " << guest->name(); - - if (!bestShoe || bestShoe->shoe()->price() < guest->shoe()->price()) - bestShoe = guest; - } - if (bestShoe) - qInfo() << bestShoe->name() << "is wearing the best shoes!"; - - return EXIT_SUCCESS; - } - - qWarning() << component.errors(); - return EXIT_FAILURE; -} diff --git a/examples/qml/referenceexamples/grouped/person.cpp b/examples/qml/referenceexamples/grouped/person.cpp deleted file mode 100644 index 358fbf0ed8..0000000000 --- a/examples/qml/referenceexamples/grouped/person.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#include "person.h" - -int ShoeDescription::size() const -{ - return m_size; -} - -void ShoeDescription::setSize(int s) -{ - m_size = s; -} - -QColor ShoeDescription::color() const -{ - return m_color; -} - -void ShoeDescription::setColor(const QColor &c) -{ - m_color = c; -} - -QString ShoeDescription::brand() const -{ - return m_brand; -} - -void ShoeDescription::setBrand(const QString &b) -{ - m_brand = b; -} - -qreal ShoeDescription::price() const -{ - return m_price; -} - -void ShoeDescription::setPrice(qreal p) -{ - m_price = p; -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - m_name = n; -} - -ShoeDescription *Person::shoe() -{ - return &m_shoe; -} diff --git a/examples/qml/referenceexamples/grouped/person.h b/examples/qml/referenceexamples/grouped/person.h deleted file mode 100644 index b5fa469025..0000000000 --- a/examples/qml/referenceexamples/grouped/person.h +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#ifndef PERSON_H -#define PERSON_H - -#include <QObject> -#include <QColor> -#include <QtQml/qqml.h> - -class ShoeDescription : public QObject -{ - Q_OBJECT - Q_PROPERTY(int size READ size WRITE setSize) - Q_PROPERTY(QColor color READ color WRITE setColor) - Q_PROPERTY(QString brand READ brand WRITE setBrand) - Q_PROPERTY(qreal price READ price WRITE setPrice) - QML_ANONYMOUS -public: - using QObject::QObject; - - int size() const; - void setSize(int); - - QColor color() const; - void setColor(const QColor &); - - QString brand() const; - void setBrand(const QString &); - - qreal price() const; - void setPrice(qreal); - -private: - int m_size = 0; - QColor m_color; - QString m_brand; - qreal m_price = 0; -}; - -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) -// ![1] - Q_PROPERTY(ShoeDescription *shoe READ shoe) -// ![1] - QML_ANONYMOUS -public: - using QObject::QObject; - - QString name() const; - void setName(const QString &); - - ShoeDescription *shoe(); -private: - QString m_name; - ShoeDescription m_shoe; -}; - -class Boy : public Person -{ - Q_OBJECT - QML_ELEMENT -public: - using Person::Person; -}; - -class Girl : public Person -{ - Q_OBJECT - QML_ELEMENT -public: - using Person::Person; -}; - -#endif // PERSON_H |