diff options
Diffstat (limited to 'examples/qml/referenceexamples/properties')
9 files changed, 0 insertions, 302 deletions
diff --git a/examples/qml/referenceexamples/properties/CMakeLists.txt b/examples/qml/referenceexamples/properties/CMakeLists.txt deleted file mode 100644 index dbe521d17d..0000000000 --- a/examples/qml/referenceexamples/properties/CMakeLists.txt +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright (C) 2022 The Qt Company Ltd. -# SPDX-License-Identifier: BSD-3-Clause - -cmake_minimum_required(VERSION 3.16) -project(properties LANGUAGES CXX) - -set(CMAKE_AUTOMOC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/qml/referenceexamples/properties") - -find_package(Qt6 REQUIRED COMPONENTS Core Qml) - -qt_add_executable(properties - birthdayparty.cpp birthdayparty.h - main.cpp - person.cpp person.h -) - -set_target_properties(properties PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) - -target_link_libraries(properties PUBLIC - Qt::Core - Qt::Qml -) - -qt_add_qml_module(properties - URI People - QML_FILES example.qml - NO_RESOURCE_TARGET_PATH -) - -install(TARGETS properties - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/qml/referenceexamples/properties/birthdayparty.cpp b/examples/qml/referenceexamples/properties/birthdayparty.cpp deleted file mode 100644 index 2f97634abc..0000000000 --- a/examples/qml/referenceexamples/properties/birthdayparty.cpp +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#include "birthdayparty.h" - -// ![0] -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QQmlListProperty<Person> BirthdayParty::guests() -{ - return {this, this, - &BirthdayParty::appendGuest, - &BirthdayParty::guestCount, - &BirthdayParty::guest, - &BirthdayParty::clearGuests, - &BirthdayParty::replaceGuest, - &BirthdayParty::removeLastGuest}; -} - -void BirthdayParty::appendGuest(Person *p) -{ - m_guests.append(p); -} - -qsizetype BirthdayParty::guestCount() const -{ - return m_guests.count(); -} - -Person *BirthdayParty::guest(qsizetype index) const -{ - return m_guests.at(index); -} - -void BirthdayParty::clearGuests() { - m_guests.clear(); -} - -void BirthdayParty::replaceGuest(qsizetype index, Person *p) -{ - m_guests[index] = p; -} - -void BirthdayParty::removeLastGuest() -{ - m_guests.removeLast(); -} - -// ![0] - -void BirthdayParty::appendGuest(QQmlListProperty<Person> *list, Person *p) -{ - reinterpret_cast< BirthdayParty *>(list->data)->appendGuest(p); -} - -void BirthdayParty::clearGuests(QQmlListProperty<Person>* list) -{ - reinterpret_cast< BirthdayParty *>(list->data)->clearGuests(); -} - -void BirthdayParty::replaceGuest(QQmlListProperty<Person> *list, qsizetype i, Person *p) -{ - reinterpret_cast< BirthdayParty* >(list->data)->replaceGuest(i, p); -} - -void BirthdayParty::removeLastGuest(QQmlListProperty<Person> *list) -{ - reinterpret_cast< BirthdayParty* >(list->data)->removeLastGuest(); -} - -Person* BirthdayParty::guest(QQmlListProperty<Person> *list, qsizetype i) -{ - return reinterpret_cast< BirthdayParty* >(list->data)->guest(i); -} - -qsizetype BirthdayParty::guestCount(QQmlListProperty<Person> *list) -{ - return reinterpret_cast< BirthdayParty* >(list->data)->guestCount(); -} diff --git a/examples/qml/referenceexamples/properties/birthdayparty.h b/examples/qml/referenceexamples/properties/birthdayparty.h deleted file mode 100644 index 239626da17..0000000000 --- a/examples/qml/referenceexamples/properties/birthdayparty.h +++ /dev/null @@ -1,52 +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 <QList> -#include <QQmlListProperty> -#include "person.h" - -// ![0] -class BirthdayParty : public QObject -{ - Q_OBJECT -// ![0] -// ![1] - Q_PROPERTY(Person *host READ host WRITE setHost) -// ![1] -// ![2] - Q_PROPERTY(QQmlListProperty<Person> guests READ guests) -// ![2] -// ![3] - QML_ELEMENT -public: - using QObject::QObject; - - Person *host() const; - void setHost(Person *); - - QQmlListProperty<Person> guests(); - void appendGuest(Person *); - qsizetype guestCount() const; - Person *guest(qsizetype) const; - void clearGuests(); - void replaceGuest(qsizetype, Person *); - void removeLastGuest(); - -private: - static void appendGuest(QQmlListProperty<Person> *, Person *); - static qsizetype guestCount(QQmlListProperty<Person> *); - static Person* guest(QQmlListProperty<Person> *, qsizetype); - static void clearGuests(QQmlListProperty<Person> *); - static void replaceGuest(QQmlListProperty<Person> *, qsizetype, Person *); - static void removeLastGuest(QQmlListProperty<Person> *); - - Person *m_host = nullptr; - QList<Person *> m_guests; -}; -// ![3] - -#endif // BIRTHDAYPARTY_H diff --git a/examples/qml/referenceexamples/properties/example.qml b/examples/qml/referenceexamples/properties/example.qml deleted file mode 100644 index 52fb3344f0..0000000000 --- a/examples/qml/referenceexamples/properties/example.qml +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -import People - -// ![0] -BirthdayParty { - host: Person { - name: "Bob Jones" - shoeSize: 12 - } - guests: [ - Person { name: "Leo Hodges" }, - Person { name: "Jack Smith" }, - Person { name: "Anne Brown" } - ] -} -// ![0] diff --git a/examples/qml/referenceexamples/properties/main.cpp b/examples/qml/referenceexamples/properties/main.cpp deleted file mode 100644 index f381686dbc..0000000000 --- a/examples/qml/referenceexamples/properties/main.cpp +++ /dev/null @@ -1,28 +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!\n" - "They are inviting:"; - for (qsizetype ii = 0; ii < party->guestCount(); ++ii) - qInfo() << " " << party->guest(ii)->name(); - return EXIT_SUCCESS; - } - - qWarning() << component.errors(); - return EXIT_FAILURE; -} diff --git a/examples/qml/referenceexamples/properties/person.cpp b/examples/qml/referenceexamples/properties/person.cpp deleted file mode 100644 index ab7aefcbee..0000000000 --- a/examples/qml/referenceexamples/properties/person.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#include "person.h" - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - m_name = n; -} - -int Person::shoeSize() const -{ - return m_shoeSize; -} - -void Person::setShoeSize(int s) -{ - m_shoeSize = s; -} diff --git a/examples/qml/referenceexamples/properties/person.h b/examples/qml/referenceexamples/properties/person.h deleted file mode 100644 index d8d4941183..0000000000 --- a/examples/qml/referenceexamples/properties/person.h +++ /dev/null @@ -1,30 +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 <QtQml/qqml.h> - -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) - QML_ELEMENT -public: - using QObject::QObject; - - QString name() const; - void setName(const QString &); - - int shoeSize() const; - void setShoeSize(int); - -private: - QString m_name; - int m_shoeSize = 0; -}; - -#endif // PERSON_H diff --git a/examples/qml/referenceexamples/properties/properties.pro b/examples/qml/referenceexamples/properties/properties.pro deleted file mode 100644 index 6697afa2c5..0000000000 --- a/examples/qml/referenceexamples/properties/properties.pro +++ /dev/null @@ -1,15 +0,0 @@ -QT = core 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 += properties.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/qml/referenceexamples/properties -INSTALLS += target diff --git a/examples/qml/referenceexamples/properties/properties.qrc b/examples/qml/referenceexamples/properties/properties.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/qml/referenceexamples/properties/properties.qrc +++ /dev/null @@ -1,5 +0,0 @@ -<!DOCTYPE RCC><RCC version="1.0"> -<qresource> - <file>example.qml</file> -</qresource> -</RCC> |