aboutsummaryrefslogtreecommitdiffstats
path: root/examples/qml/referenceexamples/methods
diff options
context:
space:
mode:
Diffstat (limited to 'examples/qml/referenceexamples/methods')
-rw-r--r--examples/qml/referenceexamples/methods/CMakeLists.txt43
-rw-r--r--examples/qml/referenceexamples/methods/birthdayparty.cpp39
-rw-r--r--examples/qml/referenceexamples/methods/birthdayparty.h36
-rw-r--r--examples/qml/referenceexamples/methods/example.qml21
-rw-r--r--examples/qml/referenceexamples/methods/main.cpp29
-rw-r--r--examples/qml/referenceexamples/methods/methods.pro15
-rw-r--r--examples/qml/referenceexamples/methods/methods.qrc5
-rw-r--r--examples/qml/referenceexamples/methods/person.cpp24
-rw-r--r--examples/qml/referenceexamples/methods/person.h30
9 files changed, 0 insertions, 242 deletions
diff --git a/examples/qml/referenceexamples/methods/CMakeLists.txt b/examples/qml/referenceexamples/methods/CMakeLists.txt
deleted file mode 100644
index 57c0733723..0000000000
--- a/examples/qml/referenceexamples/methods/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(methods LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/qml/referenceexamples/methods")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Qml)
-
-qt_add_executable(methods
- birthdayparty.cpp birthdayparty.h
- main.cpp
- person.cpp person.h
-)
-
-set_target_properties(methods PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(methods PUBLIC
- Qt::Core
- Qt::Qml
-)
-
-qt_add_qml_module(methods
- URI People
- QML_FILES example.qml
- NO_RESOURCE_TARGET_PATH
-)
-
-install(TARGETS methods
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/qml/referenceexamples/methods/birthdayparty.cpp b/examples/qml/referenceexamples/methods/birthdayparty.cpp
deleted file mode 100644
index 35ae42f779..0000000000
--- a/examples/qml/referenceexamples/methods/birthdayparty.cpp
+++ /dev/null
@@ -1,39 +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, &m_guests};
-}
-
-qsizetype BirthdayParty::guestCount() const
-{
- return m_guests.count();
-}
-
-Person *BirthdayParty::guest(qsizetype index) const
-{
- return m_guests.at(index);
-}
-
-void BirthdayParty::invite(const QString &name)
-{
- auto *person = new Person(this);
- person->setName(name);
- m_guests.append(person);
-}
-// ![0]
-
diff --git a/examples/qml/referenceexamples/methods/birthdayparty.h b/examples/qml/referenceexamples/methods/birthdayparty.h
deleted file mode 100644
index 796464c333..0000000000
--- a/examples/qml/referenceexamples/methods/birthdayparty.h
+++ /dev/null
@@ -1,36 +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)
- QML_ELEMENT
-public:
- using QObject::QObject;
-
- Person *host() const;
- void setHost(Person *);
-
- QQmlListProperty<Person> guests();
- qsizetype guestCount() const;
- Person *guest(qsizetype) const;
-
-// ![0]
- Q_INVOKABLE void invite(const QString &name);
-// ![0]
-
-private:
- Person *m_host = nullptr;
- QList<Person *> m_guests;
-};
-
-#endif // BIRTHDAYPARTY_H
diff --git a/examples/qml/referenceexamples/methods/example.qml b/examples/qml/referenceexamples/methods/example.qml
deleted file mode 100644
index 41d053edd2..0000000000
--- a/examples/qml/referenceexamples/methods/example.qml
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-// ![0]
-import QtQuick
-import People
-
-BirthdayParty {
- host: Person {
- name: "Bob Jones"
- shoeSize: 12
- }
- guests: [
- Person { name: "Leo Hodges" },
- Person { name: "Jack Smith" },
- Person { name: "Anne Brown" }
- ]
-
- Component.onCompleted: invite("William Green")
-}
-// ![0]
diff --git a/examples/qml/referenceexamples/methods/main.cpp b/examples/qml/referenceexamples/methods/main.cpp
deleted file mode 100644
index dd9b03566b..0000000000
--- a/examples/qml/referenceexamples/methods/main.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 <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!"
- << "\nThey 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/methods/methods.pro b/examples/qml/referenceexamples/methods/methods.pro
deleted file mode 100644
index 2a5f3cff41..0000000000
--- a/examples/qml/referenceexamples/methods/methods.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 += methods.qrc
-
-target.path = $$[QT_INSTALL_EXAMPLES]/qml/referenceexamples/methods
-INSTALLS += target
diff --git a/examples/qml/referenceexamples/methods/methods.qrc b/examples/qml/referenceexamples/methods/methods.qrc
deleted file mode 100644
index e2fa01d5e7..0000000000
--- a/examples/qml/referenceexamples/methods/methods.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/methods/person.cpp b/examples/qml/referenceexamples/methods/person.cpp
deleted file mode 100644
index ab7aefcbee..0000000000
--- a/examples/qml/referenceexamples/methods/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/methods/person.h b/examples/qml/referenceexamples/methods/person.h
deleted file mode 100644
index d8d4941183..0000000000
--- a/examples/qml/referenceexamples/methods/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