From 76282f480e0db0b308429324ebcab7f3abd1189e Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 27 Aug 2019 11:39:00 +0200 Subject: Use qmlRegisterAnonymousType in examples and tests Change-Id: I511d18ad8f73ea77a208e4448a8f86e5be5facc3 Reviewed-by: Fabian Kosmale Reviewed-by: Simon Hausmann --- examples/qml/referenceexamples/attached/main.cpp | 6 +++--- examples/qml/referenceexamples/binding/main.cpp | 6 +++--- examples/qml/referenceexamples/coercion/main.cpp | 2 +- examples/qml/referenceexamples/default/main.cpp | 2 +- examples/qml/referenceexamples/grouped/main.cpp | 4 ++-- examples/qml/referenceexamples/signal/main.cpp | 6 +++--- examples/qml/referenceexamples/valuesource/main.cpp | 6 +++--- 7 files changed, 16 insertions(+), 16 deletions(-) (limited to 'examples/qml') diff --git a/examples/qml/referenceexamples/attached/main.cpp b/examples/qml/referenceexamples/attached/main.cpp index 581b033dfc..444acfdee7 100644 --- a/examples/qml/referenceexamples/attached/main.cpp +++ b/examples/qml/referenceexamples/attached/main.cpp @@ -58,10 +58,10 @@ int main(int argc, char ** argv) { QCoreApplication app(argc, argv); - qmlRegisterType(); + qmlRegisterAnonymousType("People", 1); qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType(); - qmlRegisterType(); + qmlRegisterAnonymousType("People", 1); + qmlRegisterAnonymousType("People", 1); qmlRegisterType("People", 1,0, "Boy"); qmlRegisterType("People", 1,0, "Girl"); diff --git a/examples/qml/referenceexamples/binding/main.cpp b/examples/qml/referenceexamples/binding/main.cpp index 99187eba3e..18a424ff38 100644 --- a/examples/qml/referenceexamples/binding/main.cpp +++ b/examples/qml/referenceexamples/binding/main.cpp @@ -58,11 +58,11 @@ int main(int argc, char ** argv) { QCoreApplication app(argc, argv); - qmlRegisterType(); + qmlRegisterAnonymousType("People", 1); qmlRegisterType("People", 1,0, "BirthdayParty"); qmlRegisterType("People", 1,0, "HappyBirthdaySong"); - qmlRegisterType(); - qmlRegisterType(); + qmlRegisterAnonymousType("People", 1); + qmlRegisterAnonymousType("People", 1); qmlRegisterType("People", 1,0, "Boy"); qmlRegisterType("People", 1,0, "Girl"); diff --git a/examples/qml/referenceexamples/coercion/main.cpp b/examples/qml/referenceexamples/coercion/main.cpp index 262cdf6320..b7d211b73a 100644 --- a/examples/qml/referenceexamples/coercion/main.cpp +++ b/examples/qml/referenceexamples/coercion/main.cpp @@ -60,7 +60,7 @@ int main(int argc, char ** argv) qmlRegisterType("People", 1,0, "BirthdayParty"); //![0] - qmlRegisterType(); + qmlRegisterAnonymousType("People", 1); //![0] //![register boy girl] diff --git a/examples/qml/referenceexamples/default/main.cpp b/examples/qml/referenceexamples/default/main.cpp index 017d6495cd..c63a3a5788 100644 --- a/examples/qml/referenceexamples/default/main.cpp +++ b/examples/qml/referenceexamples/default/main.cpp @@ -59,7 +59,7 @@ int main(int argc, char ** argv) QCoreApplication app(argc, argv); qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType(); + qmlRegisterAnonymousType("People", 1); qmlRegisterType("People", 1,0, "Boy"); qmlRegisterType("People", 1,0, "Girl"); diff --git a/examples/qml/referenceexamples/grouped/main.cpp b/examples/qml/referenceexamples/grouped/main.cpp index 14cd64fe68..a237006e29 100644 --- a/examples/qml/referenceexamples/grouped/main.cpp +++ b/examples/qml/referenceexamples/grouped/main.cpp @@ -59,8 +59,8 @@ int main(int argc, char ** argv) QCoreApplication app(argc, argv); qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType(); - qmlRegisterType(); + qmlRegisterAnonymousType("People", 1); + qmlRegisterAnonymousType("People", 1); qmlRegisterType("People", 1,0, "Boy"); qmlRegisterType("People", 1,0, "Girl"); diff --git a/examples/qml/referenceexamples/signal/main.cpp b/examples/qml/referenceexamples/signal/main.cpp index bb75e02bc2..c62dd8ffc0 100644 --- a/examples/qml/referenceexamples/signal/main.cpp +++ b/examples/qml/referenceexamples/signal/main.cpp @@ -58,10 +58,10 @@ int main(int argc, char ** argv) { QCoreApplication app(argc, argv); - qmlRegisterType(); + qmlRegisterAnonymousType("People", 1); qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType(); - qmlRegisterType(); + qmlRegisterAnonymousType("People", 1); + qmlRegisterAnonymousType("People", 1); qmlRegisterType("People", 1,0, "Boy"); qmlRegisterType("People", 1,0, "Girl"); diff --git a/examples/qml/referenceexamples/valuesource/main.cpp b/examples/qml/referenceexamples/valuesource/main.cpp index 4bef695fe2..246954005a 100644 --- a/examples/qml/referenceexamples/valuesource/main.cpp +++ b/examples/qml/referenceexamples/valuesource/main.cpp @@ -59,11 +59,11 @@ int main(int argc, char ** argv) { QCoreApplication app(argc, argv); - qmlRegisterType(); + qmlRegisterAnonymousType("People", 1); qmlRegisterType("People", 1,0, "BirthdayParty"); qmlRegisterType("People", 1,0, "HappyBirthdaySong"); - qmlRegisterType(); - qmlRegisterType(); + qmlRegisterAnonymousType("People", 1); + qmlRegisterAnonymousType("People", 1); qmlRegisterType("People", 1,0, "Boy"); qmlRegisterType("People", 1,0, "Girl"); -- cgit v1.2.3 From d045cd4330afee92a3c5c86e51aefc2299ab3ad9 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 19 Aug 2019 11:07:52 +0200 Subject: Reference Examples: Fix calls to exec() and exit codes exec() is a static member of QCoreApplication and should be called as such. In case of errors we should return a non-0 exit code from main(). Change-Id: I0fefa006841b367d06a9de1fd1284cb7caf467bd Reviewed-by: Simon Hausmann --- examples/qml/referenceexamples/adding/main.cpp | 2 +- examples/qml/referenceexamples/attached/main.cpp | 6 +++--- examples/qml/referenceexamples/binding/main.cpp | 6 +++--- examples/qml/referenceexamples/coercion/main.cpp | 7 ++++--- examples/qml/referenceexamples/default/main.cpp | 7 ++++--- examples/qml/referenceexamples/extended/main.cpp | 8 ++++---- examples/qml/referenceexamples/grouped/main.cpp | 6 +++--- examples/qml/referenceexamples/methods/main.cpp | 6 +++--- examples/qml/referenceexamples/properties/main.cpp | 6 +++--- examples/qml/referenceexamples/signal/main.cpp | 6 +++--- examples/qml/referenceexamples/valuesource/main.cpp | 6 +++--- 11 files changed, 34 insertions(+), 32 deletions(-) (limited to 'examples/qml') diff --git a/examples/qml/referenceexamples/adding/main.cpp b/examples/qml/referenceexamples/adding/main.cpp index e312149da1..87a7b75764 100644 --- a/examples/qml/referenceexamples/adding/main.cpp +++ b/examples/qml/referenceexamples/adding/main.cpp @@ -70,5 +70,5 @@ int main(int argc, char ** argv) qWarning() << component.errors(); } - return 0; + return EXIT_SUCCESS; } diff --git a/examples/qml/referenceexamples/attached/main.cpp b/examples/qml/referenceexamples/attached/main.cpp index 444acfdee7..eb70625bea 100644 --- a/examples/qml/referenceexamples/attached/main.cpp +++ b/examples/qml/referenceexamples/attached/main.cpp @@ -93,9 +93,9 @@ int main(int argc, char ** argv) qWarning() << " " << guest->name() << "RSVP date:" << qPrintable(rsvpDate.toString()); } - } else { - qWarning() << component.errors(); + return EXIT_SUCCESS; } - return 0; + qWarning() << component.errors(); + return EXIT_FAILURE; } diff --git a/examples/qml/referenceexamples/binding/main.cpp b/examples/qml/referenceexamples/binding/main.cpp index 18a424ff38..eca524dfe2 100644 --- a/examples/qml/referenceexamples/binding/main.cpp +++ b/examples/qml/referenceexamples/binding/main.cpp @@ -94,9 +94,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/coercion/main.cpp b/examples/qml/referenceexamples/coercion/main.cpp index b7d211b73a..39064f8b89 100644 --- a/examples/qml/referenceexamples/coercion/main.cpp +++ b/examples/qml/referenceexamples/coercion/main.cpp @@ -82,9 +82,10 @@ int main(int argc, char ** argv) for (int ii = 0; ii < party->guestCount(); ++ii) qWarning() << " " << party->guest(ii)->name(); - } else { - qWarning() << component.errors(); + + return EXIT_SUCCESS; } - return 0; + qWarning() << component.errors(); + return EXIT_FAILURE; } diff --git a/examples/qml/referenceexamples/default/main.cpp b/examples/qml/referenceexamples/default/main.cpp index c63a3a5788..f6ca77e82d 100644 --- a/examples/qml/referenceexamples/default/main.cpp +++ b/examples/qml/referenceexamples/default/main.cpp @@ -77,9 +77,10 @@ int main(int argc, char ** argv) for (int ii = 0; ii < party->guestCount(); ++ii) qWarning() << " " << party->guest(ii)->name(); - } else { - qWarning() << component.errors(); + + return EXIT_SUCCESS; } - return 0; + qWarning() << component.errors(); + return EXIT_FAILURE; } diff --git a/examples/qml/referenceexamples/extended/main.cpp b/examples/qml/referenceexamples/extended/main.cpp index f91cec76b1..5f8582d08f 100644 --- a/examples/qml/referenceexamples/extended/main.cpp +++ b/examples/qml/referenceexamples/extended/main.cpp @@ -70,9 +70,9 @@ int main(int argc, char ** argv) if (edit) { edit->show(); - return app.exec(); - } else { - qWarning() << component.errors(); - return 0; + return QApplication::exec(); } + + qWarning() << component.errors(); + return EXIT_FAILURE; } diff --git a/examples/qml/referenceexamples/grouped/main.cpp b/examples/qml/referenceexamples/grouped/main.cpp index a237006e29..4f4b828cef 100644 --- a/examples/qml/referenceexamples/grouped/main.cpp +++ b/examples/qml/referenceexamples/grouped/main.cpp @@ -87,9 +87,9 @@ int main(int argc, char ** argv) if (bestShoe) qWarning() << bestShoe->name() << "is wearing the best shoes!"; - } else { - qWarning() << component.errors(); + return EXIT_SUCCESS; } - return 0; + qWarning() << component.errors(); + return EXIT_FAILURE; } diff --git a/examples/qml/referenceexamples/methods/main.cpp b/examples/qml/referenceexamples/methods/main.cpp index 89404ec822..e2a1a28c8b 100644 --- a/examples/qml/referenceexamples/methods/main.cpp +++ b/examples/qml/referenceexamples/methods/main.cpp @@ -70,9 +70,9 @@ int main(int argc, char ** argv) qWarning() << "They are inviting:"; for (int ii = 0; ii < party->guestCount(); ++ii) qWarning() << " " << party->guest(ii)->name(); - } else { - qWarning() << component.errors(); + return EXIT_SUCCESS; } - return 0; + qWarning() << component.errors(); + return EXIT_FAILURE; } diff --git a/examples/qml/referenceexamples/properties/main.cpp b/examples/qml/referenceexamples/properties/main.cpp index a0a2335034..60b56bd247 100644 --- a/examples/qml/referenceexamples/properties/main.cpp +++ b/examples/qml/referenceexamples/properties/main.cpp @@ -72,9 +72,9 @@ int main(int argc, char ** argv) qWarning() << "They are inviting:"; for (int ii = 0; ii < party->guestCount(); ++ii) qWarning() << " " << party->guest(ii)->name(); - } else { - qWarning() << component.errors(); + return EXIT_SUCCESS; } - return 0; + qWarning() << component.errors(); + return EXIT_FAILURE; } diff --git a/examples/qml/referenceexamples/signal/main.cpp b/examples/qml/referenceexamples/signal/main.cpp index c62dd8ffc0..f55b4cb419 100644 --- a/examples/qml/referenceexamples/signal/main.cpp +++ b/examples/qml/referenceexamples/signal/main.cpp @@ -93,9 +93,9 @@ int main(int argc, char ** argv) } party->startParty(); - } else { - qWarning() << component.errors(); + return EXIT_SUCCESS; } - return 0; + qWarning() << component.errors(); + return EXIT_FAILURE; } diff --git a/examples/qml/referenceexamples/valuesource/main.cpp b/examples/qml/referenceexamples/valuesource/main.cpp index 246954005a..ab50f00696 100644 --- a/examples/qml/referenceexamples/valuesource/main.cpp +++ b/examples/qml/referenceexamples/valuesource/main.cpp @@ -95,9 +95,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; } -- cgit v1.2.3 From cc1a604c704f848927b3fa0a97b0a50b0b79d2a4 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 21 Aug 2019 18:34:21 +0200 Subject: Specify parameters of type registration in class declarations Using this technique we can automatically register all necessary revisions and minor versions of a type, using the metaobject system. This greatly reduces the potential for mistakes and resulting incompatibilities between versions of imports. We assume that for each type we need to register all revisions of its super types and its attached type, and that the revisions match. That is, if you import version X of type A, you will also get version X of its attached type and of any super types. As we previously didn't take these dependencies into account when manually registering the types, a number of extra revisions are now registered for some types. Potentially, we can now generate the qmltypes files at compile time, using moc. Change-Id: I7abb8a5c39f5e63ad1a0cb41a783f2c91909491b Reviewed-by: Fabian Kosmale Reviewed-by: Simon Hausmann --- examples/qml/doc/src/qml-extending.qdoc | 4 +++- examples/qml/qmlextensionplugins/plugin.cpp | 3 ++- examples/qml/referenceexamples/adding/main.cpp | 2 +- examples/qml/referenceexamples/adding/person.h | 3 +++ examples/qml/referenceexamples/attached/birthdayparty.h | 10 +++++++--- examples/qml/referenceexamples/attached/main.cpp | 9 +++------ examples/qml/referenceexamples/attached/person.h | 5 +++++ examples/qml/referenceexamples/binding/birthdayparty.h | 5 +++-- examples/qml/referenceexamples/binding/main.cpp | 9 ++------- examples/qml/referenceexamples/binding/person.h | 5 +++++ examples/qml/referenceexamples/coercion/main.cpp | 8 +------- examples/qml/referenceexamples/coercion/person.h | 6 ++++++ examples/qml/referenceexamples/default/main.cpp | 5 +---- examples/qml/referenceexamples/default/person.h | 4 ++++ examples/qml/referenceexamples/grouped/main.cpp | 6 +----- examples/qml/referenceexamples/grouped/person.h | 5 +++++ examples/qml/referenceexamples/methods/main.cpp | 3 +-- examples/qml/referenceexamples/methods/person.h | 2 ++ examples/qml/referenceexamples/properties/main.cpp | 3 +-- examples/qml/referenceexamples/properties/person.h | 2 ++ examples/qml/referenceexamples/signal/birthdayparty.h | 4 +++- examples/qml/referenceexamples/signal/main.cpp | 8 ++------ examples/qml/referenceexamples/signal/person.h | 5 +++++ examples/qml/referenceexamples/valuesource/birthdayparty.h | 4 +++- examples/qml/referenceexamples/valuesource/main.cpp | 9 ++------- examples/qml/referenceexamples/valuesource/person.h | 5 +++++ examples/qml/tutorials/extending-qml/chapter1-basics/main.cpp | 2 +- .../qml/tutorials/extending-qml/chapter1-basics/piechart.h | 1 + examples/qml/tutorials/extending-qml/chapter2-methods/main.cpp | 2 +- .../qml/tutorials/extending-qml/chapter2-methods/piechart.h | 2 +- .../qml/tutorials/extending-qml/chapter3-bindings/main.cpp | 2 +- .../qml/tutorials/extending-qml/chapter3-bindings/piechart.h | 1 + .../extending-qml/chapter4-customPropertyTypes/main.cpp | 4 +--- .../extending-qml/chapter4-customPropertyTypes/piechart.h | 2 +- .../extending-qml/chapter4-customPropertyTypes/pieslice.h | 1 + .../tutorials/extending-qml/chapter5-listproperties/main.cpp | 3 +-- .../tutorials/extending-qml/chapter5-listproperties/piechart.h | 1 + .../tutorials/extending-qml/chapter5-listproperties/pieslice.h | 1 + .../extending-qml/chapter6-plugins/import/chartsplugin.cpp | 3 +-- .../tutorials/extending-qml/chapter6-plugins/import/piechart.h | 1 + .../tutorials/extending-qml/chapter6-plugins/import/pieslice.h | 1 + 41 files changed, 93 insertions(+), 68 deletions(-) (limited to 'examples/qml') diff --git a/examples/qml/doc/src/qml-extending.qdoc b/examples/qml/doc/src/qml-extending.qdoc index e56dd90dd7..64d7235031 100644 --- a/examples/qml/doc/src/qml-extending.qdoc +++ b/examples/qml/doc/src/qml-extending.qdoc @@ -178,12 +178,14 @@ previous example. However, as we have repurposed the People class as a common base for Boy and Girl, we want to prevent it from being instantiated from QML directly - an explicit Boy or Girl should be instantiated instead. -\snippet referenceexamples/coercion/main.cpp 0 +\snippet referenceexamples/coercion/person.h 0 While we want to disallow instantiating Person from within QML, it still needs to be registered with the QML engine, so that it can be used as a property type and other types can be coerced to it. +\snippet referenceexamples/coercion/main.cpp 0 + \section2 Define Boy and Girl The implementation of Boy and Girl is trivial. diff --git a/examples/qml/qmlextensionplugins/plugin.cpp b/examples/qml/qmlextensionplugins/plugin.cpp index 4866106e4a..a6d1d3ff63 100644 --- a/examples/qml/qmlextensionplugins/plugin.cpp +++ b/examples/qml/qmlextensionplugins/plugin.cpp @@ -112,6 +112,7 @@ class TimeModel : public QObject Q_OBJECT Q_PROPERTY(int hour READ hour NOTIFY timeChanged) Q_PROPERTY(int minute READ minute NOTIFY timeChanged) + QML_NAMED_ELEMENT(Time) //![0] public: @@ -157,7 +158,7 @@ public: void registerTypes(const char *uri) override { Q_ASSERT(uri == QLatin1String("TimeExample")); - qmlRegisterType(uri, 1, 0, "Time"); + qmlRegisterTypesAndRevisions(uri, 1); } }; //![plugin] diff --git a/examples/qml/referenceexamples/adding/main.cpp b/examples/qml/referenceexamples/adding/main.cpp index 87a7b75764..ffd0e90c42 100644 --- a/examples/qml/referenceexamples/adding/main.cpp +++ b/examples/qml/referenceexamples/adding/main.cpp @@ -57,7 +57,7 @@ int main(int argc, char ** argv) { QCoreApplication app(argc, argv); //![0] - qmlRegisterType("People", 1,0, "Person"); + qmlRegisterTypesAndRevisions("People", 1); //![0] QQmlEngine engine; diff --git a/examples/qml/referenceexamples/adding/person.h b/examples/qml/referenceexamples/adding/person.h index f40c8d8086..530c335dee 100644 --- a/examples/qml/referenceexamples/adding/person.h +++ b/examples/qml/referenceexamples/adding/person.h @@ -51,12 +51,15 @@ #define PERSON_H #include +#include + //![0] 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: Person(QObject *parent = nullptr); diff --git a/examples/qml/referenceexamples/attached/birthdayparty.h b/examples/qml/referenceexamples/attached/birthdayparty.h index 15375f14d9..308d0652a8 100644 --- a/examples/qml/referenceexamples/attached/birthdayparty.h +++ b/examples/qml/referenceexamples/attached/birthdayparty.h @@ -59,6 +59,7 @@ class BirthdayPartyAttached : public QObject { Q_OBJECT Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp) + QML_ANONYMOUS public: BirthdayPartyAttached(QObject *object); @@ -75,6 +76,12 @@ class BirthdayParty : public QObject Q_PROPERTY(Person *host READ host WRITE setHost) Q_PROPERTY(QQmlListProperty guests READ guests) Q_CLASSINFO("DefaultProperty", "guests") + QML_ELEMENT + +//! [declare attached] + QML_ATTACHED(BirthdayPartyAttached) +//! [declare attached] + public: BirthdayParty(QObject *parent = nullptr); @@ -93,7 +100,4 @@ private: QList m_guests; }; -//! [declare attached] -QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) -//! [declare attached] #endif // BIRTHDAYPARTY_H diff --git a/examples/qml/referenceexamples/attached/main.cpp b/examples/qml/referenceexamples/attached/main.cpp index eb70625bea..ab1c6b9637 100644 --- a/examples/qml/referenceexamples/attached/main.cpp +++ b/examples/qml/referenceexamples/attached/main.cpp @@ -58,12 +58,9 @@ int main(int argc, char ** argv) { QCoreApplication app(argc, argv); - qmlRegisterAnonymousType("People", 1); - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterAnonymousType("People", 1); - qmlRegisterAnonymousType("People", 1); - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); + qmlRegisterTypesAndRevisions("People", 1); QQmlEngine engine; QQmlComponent component(&engine, QUrl("qrc:example.qml")); diff --git a/examples/qml/referenceexamples/attached/person.h b/examples/qml/referenceexamples/attached/person.h index 2398da38bf..239f4405c0 100644 --- a/examples/qml/referenceexamples/attached/person.h +++ b/examples/qml/referenceexamples/attached/person.h @@ -52,6 +52,7 @@ #include #include +#include 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 = 0); @@ -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); }; 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 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 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("People", 1); - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType("People", 1,0, "HappyBirthdaySong"); - qmlRegisterAnonymousType("People", 1); - qmlRegisterAnonymousType("People", 1); - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); + qmlRegisterTypesAndRevisions("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 #include +#include 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); }; diff --git a/examples/qml/referenceexamples/coercion/main.cpp b/examples/qml/referenceexamples/coercion/main.cpp index 39064f8b89..2c2bd92e8d 100644 --- a/examples/qml/referenceexamples/coercion/main.cpp +++ b/examples/qml/referenceexamples/coercion/main.cpp @@ -58,16 +58,10 @@ int main(int argc, char ** argv) { QCoreApplication app(argc, argv); - qmlRegisterType("People", 1,0, "BirthdayParty"); //![0] - qmlRegisterAnonymousType("People", 1); + qmlRegisterTypesAndRevisions("People", 1); //![0] - //![register boy girl] - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); - //![register boy girl] - QQmlEngine engine; QQmlComponent component(&engine, QUrl("qrc:example.qml")); auto *party = qobject_cast(component.create()); diff --git a/examples/qml/referenceexamples/coercion/person.h b/examples/qml/referenceexamples/coercion/person.h index 692cf4eb19..6865e0093a 100644 --- a/examples/qml/referenceexamples/coercion/person.h +++ b/examples/qml/referenceexamples/coercion/person.h @@ -51,12 +51,16 @@ #define PERSON_H #include +#include class Person : public QObject { Q_OBJECT Q_PROPERTY(QString name READ name WRITE setName) Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) + //![0] + QML_ANONYMOUS + //![0] public: Person(QObject *parent = nullptr); @@ -75,6 +79,7 @@ private: class Boy : public Person { Q_OBJECT + QML_ELEMENT public: Boy(QObject * parent = nullptr); }; @@ -83,6 +88,7 @@ public: class Girl : public Person { Q_OBJECT + QML_ELEMENT public: Girl(QObject * parent = nullptr); }; diff --git a/examples/qml/referenceexamples/default/main.cpp b/examples/qml/referenceexamples/default/main.cpp index f6ca77e82d..bbe4a239e2 100644 --- a/examples/qml/referenceexamples/default/main.cpp +++ b/examples/qml/referenceexamples/default/main.cpp @@ -58,10 +58,7 @@ int main(int argc, char ** argv) { QCoreApplication app(argc, argv); - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterAnonymousType("People", 1); - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); + qmlRegisterTypesAndRevisions("People", 1); QQmlEngine engine; QQmlComponent component(&engine, QUrl("qrc:example.qml")); diff --git a/examples/qml/referenceexamples/default/person.h b/examples/qml/referenceexamples/default/person.h index 87f69276bf..361a89c599 100644 --- a/examples/qml/referenceexamples/default/person.h +++ b/examples/qml/referenceexamples/default/person.h @@ -51,12 +51,14 @@ #define PERSON_H #include +#include class Person : public QObject { Q_OBJECT Q_PROPERTY(QString name READ name WRITE setName) Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) + QML_ANONYMOUS public: Person(QObject *parent = nullptr); @@ -73,6 +75,7 @@ private: class Boy : public Person { Q_OBJECT + QML_ELEMENT public: Boy(QObject * parent = nullptr); }; @@ -80,6 +83,7 @@ public: class Girl : public Person { Q_OBJECT + QML_ELEMENT public: Girl(QObject * parent = nullptr); }; diff --git a/examples/qml/referenceexamples/grouped/main.cpp b/examples/qml/referenceexamples/grouped/main.cpp index 4f4b828cef..e233aab5b1 100644 --- a/examples/qml/referenceexamples/grouped/main.cpp +++ b/examples/qml/referenceexamples/grouped/main.cpp @@ -58,11 +58,7 @@ int main(int argc, char ** argv) { QCoreApplication app(argc, argv); - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterAnonymousType("People", 1); - qmlRegisterAnonymousType("People", 1); - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); + qmlRegisterTypesAndRevisions("People", 1); QQmlEngine engine; QQmlComponent component(&engine, QUrl("qrc:example.qml")); diff --git a/examples/qml/referenceexamples/grouped/person.h b/examples/qml/referenceexamples/grouped/person.h index 6f6caaee7c..df507c7386 100644 --- a/examples/qml/referenceexamples/grouped/person.h +++ b/examples/qml/referenceexamples/grouped/person.h @@ -52,6 +52,7 @@ #include #include +#include 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); @@ -88,6 +90,7 @@ class Person : public QObject // ![1] Q_PROPERTY(ShoeDescription *shoe READ shoe) // ![1] + QML_ANONYMOUS public: Person(QObject *parent = nullptr); @@ -103,6 +106,7 @@ private: class Boy : public Person { Q_OBJECT + QML_ELEMENT public: Boy(QObject * parent = nullptr); }; @@ -110,6 +114,7 @@ public: class Girl : public Person { Q_OBJECT + QML_ELEMENT public: Girl(QObject * parent = nullptr); }; diff --git a/examples/qml/referenceexamples/methods/main.cpp b/examples/qml/referenceexamples/methods/main.cpp index e2a1a28c8b..4dd616f8cd 100644 --- a/examples/qml/referenceexamples/methods/main.cpp +++ b/examples/qml/referenceexamples/methods/main.cpp @@ -58,8 +58,7 @@ int main(int argc, char ** argv) { QCoreApplication app(argc, argv); - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType("People", 1,0, "Person"); + qmlRegisterTypesAndRevisions("People", 1); QQmlEngine engine; QQmlComponent component(&engine, QUrl("qrc:example.qml")); diff --git a/examples/qml/referenceexamples/methods/person.h b/examples/qml/referenceexamples/methods/person.h index 749109dc72..2407fbb1b9 100644 --- a/examples/qml/referenceexamples/methods/person.h +++ b/examples/qml/referenceexamples/methods/person.h @@ -51,12 +51,14 @@ #define PERSON_H #include +#include 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: Person(QObject *parent = nullptr); diff --git a/examples/qml/referenceexamples/properties/main.cpp b/examples/qml/referenceexamples/properties/main.cpp index 60b56bd247..216869bf6c 100644 --- a/examples/qml/referenceexamples/properties/main.cpp +++ b/examples/qml/referenceexamples/properties/main.cpp @@ -59,8 +59,7 @@ int main(int argc, char ** argv) QCoreApplication app(argc, argv); //![register list] - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType("People", 1,0, "Person"); + qmlRegisterTypesAndRevisions("People", 1); //![register list] QQmlEngine engine; diff --git a/examples/qml/referenceexamples/properties/person.h b/examples/qml/referenceexamples/properties/person.h index 749109dc72..2407fbb1b9 100644 --- a/examples/qml/referenceexamples/properties/person.h +++ b/examples/qml/referenceexamples/properties/person.h @@ -51,12 +51,14 @@ #define PERSON_H #include +#include 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: Person(QObject *parent = nullptr); diff --git a/examples/qml/referenceexamples/signal/birthdayparty.h b/examples/qml/referenceexamples/signal/birthdayparty.h index 9aecc8929c..c815518291 100644 --- a/examples/qml/referenceexamples/signal/birthdayparty.h +++ b/examples/qml/referenceexamples/signal/birthdayparty.h @@ -59,6 +59,7 @@ class BirthdayPartyAttached : public QObject { Q_OBJECT Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp) + QML_ANONYMOUS public: BirthdayPartyAttached(QObject *object); @@ -75,6 +76,8 @@ class BirthdayParty : public QObject Q_PROPERTY(Person *host READ host WRITE setHost) Q_PROPERTY(QQmlListProperty guests READ guests) Q_CLASSINFO("DefaultProperty", "guests") + QML_ELEMENT + QML_ATTACHED(BirthdayPartyAttached) public: BirthdayParty(QObject *parent = nullptr); @@ -97,6 +100,5 @@ private: Person *m_host; QList m_guests; }; -QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) #endif // BIRTHDAYPARTY_H diff --git a/examples/qml/referenceexamples/signal/main.cpp b/examples/qml/referenceexamples/signal/main.cpp index f55b4cb419..f431e2bdc8 100644 --- a/examples/qml/referenceexamples/signal/main.cpp +++ b/examples/qml/referenceexamples/signal/main.cpp @@ -58,12 +58,8 @@ int main(int argc, char ** argv) { QCoreApplication app(argc, argv); - qmlRegisterAnonymousType("People", 1); - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterAnonymousType("People", 1); - qmlRegisterAnonymousType("People", 1); - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); + qmlRegisterTypesAndRevisions("People", 1); QQmlEngine engine; QQmlComponent component(&engine, QUrl("qrc:example.qml")); diff --git a/examples/qml/referenceexamples/signal/person.h b/examples/qml/referenceexamples/signal/person.h index 06d4f2eb27..7283f39f61 100644 --- a/examples/qml/referenceexamples/signal/person.h +++ b/examples/qml/referenceexamples/signal/person.h @@ -52,6 +52,7 @@ #include #include +#include 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); }; 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 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 ab50f00696..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); - qmlRegisterAnonymousType("People", 1); - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType("People", 1,0, "HappyBirthdaySong"); - qmlRegisterAnonymousType("People", 1); - qmlRegisterAnonymousType("People", 1); - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); + qmlRegisterTypesAndRevisions("People", 1); QQmlEngine engine; QQmlComponent component(&engine, QUrl("qrc:example.qml")); 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 #include +#include 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); }; diff --git a/examples/qml/tutorials/extending-qml/chapter1-basics/main.cpp b/examples/qml/tutorials/extending-qml/chapter1-basics/main.cpp index fbff60c0e6..af50cc14f2 100644 --- a/examples/qml/tutorials/extending-qml/chapter1-basics/main.cpp +++ b/examples/qml/tutorials/extending-qml/chapter1-basics/main.cpp @@ -56,7 +56,7 @@ int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); - qmlRegisterType("Charts", 1, 0, "PieChart"); + qmlRegisterTypesAndRevisions("Charts", 1); QQuickView view; view.setResizeMode(QQuickView::SizeRootObjectToView); diff --git a/examples/qml/tutorials/extending-qml/chapter1-basics/piechart.h b/examples/qml/tutorials/extending-qml/chapter1-basics/piechart.h index 005a706db6..687f8e2b4d 100644 --- a/examples/qml/tutorials/extending-qml/chapter1-basics/piechart.h +++ b/examples/qml/tutorials/extending-qml/chapter1-basics/piechart.h @@ -59,6 +59,7 @@ class PieChart : public QQuickPaintedItem Q_OBJECT Q_PROPERTY(QString name READ name WRITE setName) Q_PROPERTY(QColor color READ color WRITE setColor) + QML_ELEMENT public: PieChart(QQuickItem *parent = 0); diff --git a/examples/qml/tutorials/extending-qml/chapter2-methods/main.cpp b/examples/qml/tutorials/extending-qml/chapter2-methods/main.cpp index fbff60c0e6..af50cc14f2 100644 --- a/examples/qml/tutorials/extending-qml/chapter2-methods/main.cpp +++ b/examples/qml/tutorials/extending-qml/chapter2-methods/main.cpp @@ -56,7 +56,7 @@ int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); - qmlRegisterType("Charts", 1, 0, "PieChart"); + qmlRegisterTypesAndRevisions("Charts", 1); QQuickView view; view.setResizeMode(QQuickView::SizeRootObjectToView); diff --git a/examples/qml/tutorials/extending-qml/chapter2-methods/piechart.h b/examples/qml/tutorials/extending-qml/chapter2-methods/piechart.h index 36bfa3ada0..271afbf653 100644 --- a/examples/qml/tutorials/extending-qml/chapter2-methods/piechart.h +++ b/examples/qml/tutorials/extending-qml/chapter2-methods/piechart.h @@ -60,7 +60,7 @@ class PieChart : public QQuickPaintedItem Q_OBJECT Q_PROPERTY(QString name READ name WRITE setName) Q_PROPERTY(QColor color READ color WRITE setColor) - + QML_ELEMENT //![1] public: //![1] diff --git a/examples/qml/tutorials/extending-qml/chapter3-bindings/main.cpp b/examples/qml/tutorials/extending-qml/chapter3-bindings/main.cpp index fbff60c0e6..af50cc14f2 100644 --- a/examples/qml/tutorials/extending-qml/chapter3-bindings/main.cpp +++ b/examples/qml/tutorials/extending-qml/chapter3-bindings/main.cpp @@ -56,7 +56,7 @@ int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); - qmlRegisterType("Charts", 1, 0, "PieChart"); + qmlRegisterTypesAndRevisions("Charts", 1); QQuickView view; view.setResizeMode(QQuickView::SizeRootObjectToView); diff --git a/examples/qml/tutorials/extending-qml/chapter3-bindings/piechart.h b/examples/qml/tutorials/extending-qml/chapter3-bindings/piechart.h index 9de2baa82e..58b1339298 100644 --- a/examples/qml/tutorials/extending-qml/chapter3-bindings/piechart.h +++ b/examples/qml/tutorials/extending-qml/chapter3-bindings/piechart.h @@ -59,6 +59,7 @@ class PieChart : public QQuickPaintedItem //![0] Q_OBJECT Q_PROPERTY(QString name READ name WRITE setName) + QML_ELEMENT //![1] Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) diff --git a/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/main.cpp b/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/main.cpp index 82355d0438..7c5d1a6885 100644 --- a/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/main.cpp +++ b/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/main.cpp @@ -59,10 +59,8 @@ int main(int argc, char *argv[]) //![0] QGuiApplication app(argc, argv); - qmlRegisterType("Charts", 1, 0, "PieChart"); - //![1] - qmlRegisterType("Charts", 1, 0, "PieSlice"); + qmlRegisterTypesAndRevisions("Charts", 1); //![1] QQuickView view; diff --git a/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/piechart.h b/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/piechart.h index 6cd09a9293..b762ce1c49 100644 --- a/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/piechart.h +++ b/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/piechart.h @@ -61,7 +61,7 @@ class PieChart : public QQuickItem Q_PROPERTY(PieSlice* pieSlice READ pieSlice WRITE setPieSlice) //![0] Q_PROPERTY(QString name READ name WRITE setName) - + QML_ELEMENT //![1] public: //![1] diff --git a/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/pieslice.h b/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/pieslice.h index 10ab4d34b6..6e64917851 100644 --- a/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/pieslice.h +++ b/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/pieslice.h @@ -58,6 +58,7 @@ class PieSlice : public QQuickPaintedItem { Q_OBJECT Q_PROPERTY(QColor color READ color WRITE setColor) + QML_ELEMENT public: PieSlice(QQuickItem *parent = 0); diff --git a/examples/qml/tutorials/extending-qml/chapter5-listproperties/main.cpp b/examples/qml/tutorials/extending-qml/chapter5-listproperties/main.cpp index 8aa6fef018..70ef103e4d 100644 --- a/examples/qml/tutorials/extending-qml/chapter5-listproperties/main.cpp +++ b/examples/qml/tutorials/extending-qml/chapter5-listproperties/main.cpp @@ -57,8 +57,7 @@ int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); - qmlRegisterType("Charts", 1, 0, "PieChart"); - qmlRegisterType("Charts", 1, 0, "PieSlice"); + qmlRegisterTypesAndRevisions("Charts", 1); QQuickView view; view.setResizeMode(QQuickView::SizeRootObjectToView); diff --git a/examples/qml/tutorials/extending-qml/chapter5-listproperties/piechart.h b/examples/qml/tutorials/extending-qml/chapter5-listproperties/piechart.h index 9b3390b902..236fa6796f 100644 --- a/examples/qml/tutorials/extending-qml/chapter5-listproperties/piechart.h +++ b/examples/qml/tutorials/extending-qml/chapter5-listproperties/piechart.h @@ -61,6 +61,7 @@ class PieChart : public QQuickItem Q_PROPERTY(QQmlListProperty slices READ slices) //![0] Q_PROPERTY(QString name READ name WRITE setName) + QML_ELEMENT //![1] public: diff --git a/examples/qml/tutorials/extending-qml/chapter5-listproperties/pieslice.h b/examples/qml/tutorials/extending-qml/chapter5-listproperties/pieslice.h index f8f7f7c36a..0b290851f0 100644 --- a/examples/qml/tutorials/extending-qml/chapter5-listproperties/pieslice.h +++ b/examples/qml/tutorials/extending-qml/chapter5-listproperties/pieslice.h @@ -60,6 +60,7 @@ class PieSlice : public QQuickPaintedItem Q_PROPERTY(QColor color READ color WRITE setColor) Q_PROPERTY(int fromAngle READ fromAngle WRITE setFromAngle) Q_PROPERTY(int angleSpan READ angleSpan WRITE setAngleSpan) + QML_ELEMENT //![0] public: diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/chartsplugin.cpp b/examples/qml/tutorials/extending-qml/chapter6-plugins/import/chartsplugin.cpp index ce8b95b6b6..74d382ec57 100644 --- a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/chartsplugin.cpp +++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/import/chartsplugin.cpp @@ -55,8 +55,7 @@ void ChartsPlugin::registerTypes(const char *uri) { - qmlRegisterType(uri, 1, 0, "PieChart"); - qmlRegisterType(uri, 1, 0, "PieSlice"); + qmlRegisterTypesAndRevisions(uri, 1); } //![0] diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/piechart.h b/examples/qml/tutorials/extending-qml/chapter6-plugins/import/piechart.h index cd67bdf34a..e6b768b274 100644 --- a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/piechart.h +++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/import/piechart.h @@ -59,6 +59,7 @@ class PieChart : public QQuickItem Q_OBJECT Q_PROPERTY(QQmlListProperty slices READ slices) Q_PROPERTY(QString name READ name WRITE setName) + QML_ELEMENT public: PieChart(QQuickItem *parent = 0); diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/pieslice.h b/examples/qml/tutorials/extending-qml/chapter6-plugins/import/pieslice.h index 71cc20a369..091870bd51 100644 --- a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/pieslice.h +++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/import/pieslice.h @@ -59,6 +59,7 @@ class PieSlice : public QQuickPaintedItem Q_PROPERTY(QColor color READ color WRITE setColor) Q_PROPERTY(int fromAngle READ fromAngle WRITE setFromAngle) Q_PROPERTY(int angleSpan READ angleSpan WRITE setAngleSpan) + QML_ELEMENT public: PieSlice(QQuickItem *parent = 0); -- cgit v1.2.3