diff options
Diffstat (limited to 'examples/qml/referenceexamples/binding')
-rw-r--r-- | examples/qml/referenceexamples/binding/birthdayparty.h | 5 | ||||
-rw-r--r-- | examples/qml/referenceexamples/binding/main.cpp | 9 | ||||
-rw-r--r-- | examples/qml/referenceexamples/binding/person.h | 5 |
3 files changed, 10 insertions, 9 deletions
diff --git a/examples/qml/referenceexamples/binding/birthdayparty.h b/examples/qml/referenceexamples/binding/birthdayparty.h index 15e1908ece..3cd5cf1c9a 100644 --- a/examples/qml/referenceexamples/binding/birthdayparty.h +++ b/examples/qml/referenceexamples/binding/birthdayparty.h @@ -60,6 +60,7 @@ class BirthdayPartyAttached : public QObject { Q_OBJECT Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp NOTIFY rsvpChanged) + QML_ANONYMOUS public: BirthdayPartyAttached(QObject *object); @@ -82,6 +83,8 @@ class BirthdayParty : public QObject Q_PROPERTY(QQmlListProperty<Person> guests READ guests) Q_PROPERTY(QString announcement READ announcement WRITE setAnnouncement) Q_CLASSINFO("DefaultProperty", "guests") + QML_ELEMENT + QML_ATTACHED(BirthdayPartyAttached) public: BirthdayParty(QObject *parent = nullptr); @@ -107,6 +110,4 @@ private: QList<Person *> m_guests; }; -QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) - #endif // BIRTHDAYPARTY_H diff --git a/examples/qml/referenceexamples/binding/main.cpp b/examples/qml/referenceexamples/binding/main.cpp index eca524dfe2..8c6e3222d8 100644 --- a/examples/qml/referenceexamples/binding/main.cpp +++ b/examples/qml/referenceexamples/binding/main.cpp @@ -58,13 +58,8 @@ int main(int argc, char ** argv) { QCoreApplication app(argc, argv); - qmlRegisterAnonymousType<BirthdayPartyAttached>("People", 1); - qmlRegisterType<BirthdayParty>("People", 1,0, "BirthdayParty"); - qmlRegisterType<HappyBirthdaySong>("People", 1,0, "HappyBirthdaySong"); - qmlRegisterAnonymousType<ShoeDescription>("People", 1); - qmlRegisterAnonymousType<Person>("People", 1); - 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")); diff --git a/examples/qml/referenceexamples/binding/person.h b/examples/qml/referenceexamples/binding/person.h index 543b24f971..af9864950a 100644 --- a/examples/qml/referenceexamples/binding/person.h +++ b/examples/qml/referenceexamples/binding/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 NOTIFY shoeChanged) Q_PROPERTY(QString brand READ brand WRITE setBrand NOTIFY shoeChanged) Q_PROPERTY(qreal price READ price WRITE setPrice NOTIFY shoeChanged) + QML_ANONYMOUS public: ShoeDescription(QObject *parent = nullptr); @@ -91,6 +93,7 @@ class Person : public QObject // ![0] Q_PROPERTY(ShoeDescription *shoe READ shoe CONSTANT) // ![0] + QML_ANONYMOUS public: Person(QObject *parent = nullptr); @@ -109,6 +112,7 @@ private: class Boy : public Person { Q_OBJECT + QML_ELEMENT public: Boy(QObject * parent = nullptr); }; @@ -116,6 +120,7 @@ public: class Girl : public Person { Q_OBJECT + QML_ELEMENT public: Girl(QObject * parent = nullptr); }; |