aboutsummaryrefslogtreecommitdiffstats
path: root/examples/qml/referenceexamples/valuesource
diff options
context:
space:
mode:
Diffstat (limited to 'examples/qml/referenceexamples/valuesource')
-rw-r--r--examples/qml/referenceexamples/valuesource/birthdayparty.h4
-rw-r--r--examples/qml/referenceexamples/valuesource/main.cpp15
-rw-r--r--examples/qml/referenceexamples/valuesource/person.h5
3 files changed, 13 insertions, 11 deletions
diff --git a/examples/qml/referenceexamples/valuesource/birthdayparty.h b/examples/qml/referenceexamples/valuesource/birthdayparty.h
index 18a9b96147..25e2342937 100644
--- a/examples/qml/referenceexamples/valuesource/birthdayparty.h
+++ b/examples/qml/referenceexamples/valuesource/birthdayparty.h
@@ -60,6 +60,7 @@ class BirthdayPartyAttached : public QObject
{
Q_OBJECT
Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp)
+ QML_ANONYMOUS
public:
BirthdayPartyAttached(QObject *object);
@@ -79,6 +80,8 @@ class BirthdayParty : public QObject
Q_PROPERTY(QString announcement READ announcement WRITE setAnnouncement)
// ![0]
Q_CLASSINFO("DefaultProperty", "guests")
+ QML_ELEMENT
+ QML_ATTACHED(BirthdayPartyAttached)
public:
BirthdayParty(QObject *parent = nullptr);
@@ -102,6 +105,5 @@ private:
Person *m_host;
QList<Person *> m_guests;
};
-QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES)
#endif // BIRTHDAYPARTY_H
diff --git a/examples/qml/referenceexamples/valuesource/main.cpp b/examples/qml/referenceexamples/valuesource/main.cpp
index 4bef695fe2..72e75fdea1 100644
--- a/examples/qml/referenceexamples/valuesource/main.cpp
+++ b/examples/qml/referenceexamples/valuesource/main.cpp
@@ -59,13 +59,8 @@ int main(int argc, char ** argv)
{
QCoreApplication app(argc, argv);
- qmlRegisterType<BirthdayPartyAttached>();
- qmlRegisterType<BirthdayParty>("People", 1,0, "BirthdayParty");
- qmlRegisterType<HappyBirthdaySong>("People", 1,0, "HappyBirthdaySong");
- qmlRegisterType<ShoeDescription>();
- qmlRegisterType<Person>();
- qmlRegisterType<Boy>("People", 1,0, "Boy");
- qmlRegisterType<Girl>("People", 1,0, "Girl");
+ qmlRegisterTypesAndRevisions<BirthdayPartyAttached, BirthdayParty, HappyBirthdaySong,
+ ShoeDescription, Person, Boy, Girl>("People", 1);
QQmlEngine engine;
QQmlComponent component(&engine, QUrl("qrc:example.qml"));
@@ -95,9 +90,9 @@ int main(int argc, char ** argv)
}
party->startParty();
- } else {
- qWarning() << component.errors();
+ return QCoreApplication::exec();
}
- return app.exec();
+ qWarning() << component.errors();
+ return EXIT_FAILURE;
}
diff --git a/examples/qml/referenceexamples/valuesource/person.h b/examples/qml/referenceexamples/valuesource/person.h
index 06d4f2eb27..7283f39f61 100644
--- a/examples/qml/referenceexamples/valuesource/person.h
+++ b/examples/qml/referenceexamples/valuesource/person.h
@@ -52,6 +52,7 @@
#include <QObject>
#include <QColor>
+#include <QtQml/qqml.h>
class ShoeDescription : public QObject
{
@@ -60,6 +61,7 @@ class ShoeDescription : public QObject
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:
ShoeDescription(QObject *parent = nullptr);
@@ -86,6 +88,7 @@ class Person : public QObject
Q_OBJECT
Q_PROPERTY(QString name READ name WRITE setName)
Q_PROPERTY(ShoeDescription *shoe READ shoe)
+ QML_ANONYMOUS
public:
Person(QObject *parent = nullptr);
@@ -101,6 +104,7 @@ private:
class Boy : public Person
{
Q_OBJECT
+ QML_ELEMENT
public:
Boy(QObject * parent = nullptr);
};
@@ -108,6 +112,7 @@ public:
class Girl : public Person
{
Q_OBJECT
+ QML_ELEMENT
public:
Girl(QObject * parent = nullptr);
};