diff options
Diffstat (limited to 'examples')
75 files changed, 163 insertions, 117 deletions
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<TimeModel>(uri, 1, 0, "Time"); + qmlRegisterTypesAndRevisions<TimeModel>(uri, 1); } }; //![plugin] diff --git a/examples/qml/referenceexamples/adding/main.cpp b/examples/qml/referenceexamples/adding/main.cpp index e312149da1..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<Person>("People", 1,0, "Person"); + qmlRegisterTypesAndRevisions<Person>("People", 1); //![0] QQmlEngine engine; @@ -70,5 +70,5 @@ int main(int argc, char ** argv) qWarning() << component.errors(); } - return 0; + return EXIT_SUCCESS; } 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 <QObject> +#include <QtQml/qqml.h> + //![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<Person> 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<Person *> 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 581b033dfc..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); - qmlRegisterType<BirthdayPartyAttached>(); - qmlRegisterType<BirthdayParty>("People", 1,0, "BirthdayParty"); - qmlRegisterType<ShoeDescription>(); - qmlRegisterType<Person>(); - qmlRegisterType<Boy>("People", 1,0, "Boy"); - qmlRegisterType<Girl>("People", 1,0, "Girl"); + qmlRegisterTypesAndRevisions<BirthdayPartyAttached, + BirthdayParty, ShoeDescription, + Person, Boy, Girl>("People", 1); QQmlEngine engine; QQmlComponent component(&engine, QUrl("qrc:example.qml")); @@ -93,9 +90,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/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 <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 = 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<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 99187eba3e..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); - 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")); @@ -94,9 +89,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/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); }; diff --git a/examples/qml/referenceexamples/coercion/main.cpp b/examples/qml/referenceexamples/coercion/main.cpp index 262cdf6320..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<BirthdayParty>("People", 1,0, "BirthdayParty"); //![0] - qmlRegisterType<Person>(); + qmlRegisterTypesAndRevisions<BirthdayParty, Person, Boy, Girl>("People", 1); //![0] - //![register boy girl] - qmlRegisterType<Boy>("People", 1,0, "Boy"); - qmlRegisterType<Girl>("People", 1,0, "Girl"); - //![register boy girl] - QQmlEngine engine; QQmlComponent component(&engine, QUrl("qrc:example.qml")); auto *party = qobject_cast<BirthdayParty *>(component.create()); @@ -82,9 +76,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/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 <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) + //![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 017d6495cd..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<BirthdayParty>("People", 1,0, "BirthdayParty"); - qmlRegisterType<Person>(); - qmlRegisterType<Boy>("People", 1,0, "Boy"); - qmlRegisterType<Girl>("People", 1,0, "Girl"); + qmlRegisterTypesAndRevisions<BirthdayParty, Person, Boy, Girl>("People", 1); QQmlEngine engine; QQmlComponent component(&engine, QUrl("qrc:example.qml")); @@ -77,9 +74,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/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 <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_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/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 14cd64fe68..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<BirthdayParty>("People", 1,0, "BirthdayParty"); - qmlRegisterType<ShoeDescription>(); - qmlRegisterType<Person>(); - qmlRegisterType<Boy>("People", 1,0, "Boy"); - qmlRegisterType<Girl>("People", 1,0, "Girl"); + qmlRegisterTypesAndRevisions<BirthdayParty, ShoeDescription, Person, Boy, Girl>("People", 1); QQmlEngine engine; QQmlComponent component(&engine, QUrl("qrc:example.qml")); @@ -87,9 +83,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/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 <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); @@ -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 89404ec822..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<BirthdayParty>("People", 1,0, "BirthdayParty"); - qmlRegisterType<Person>("People", 1,0, "Person"); + qmlRegisterTypesAndRevisions<BirthdayParty, Person>("People", 1); QQmlEngine engine; QQmlComponent component(&engine, QUrl("qrc:example.qml")); @@ -70,9 +69,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/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 <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: Person(QObject *parent = nullptr); diff --git a/examples/qml/referenceexamples/properties/main.cpp b/examples/qml/referenceexamples/properties/main.cpp index a0a2335034..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<BirthdayParty>("People", 1,0, "BirthdayParty"); - qmlRegisterType<Person>("People", 1,0, "Person"); + qmlRegisterTypesAndRevisions<BirthdayParty, Person>("People", 1); //![register list] QQmlEngine engine; @@ -72,9 +71,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/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 <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: 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<Person> 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<Person *> 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 bb75e02bc2..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); - qmlRegisterType<BirthdayPartyAttached>(); - qmlRegisterType<BirthdayParty>("People", 1,0, "BirthdayParty"); - qmlRegisterType<ShoeDescription>(); - qmlRegisterType<Person>(); - qmlRegisterType<Boy>("People", 1,0, "Boy"); - qmlRegisterType<Girl>("People", 1,0, "Girl"); + qmlRegisterTypesAndRevisions<BirthdayPartyAttached, BirthdayParty, ShoeDescription, + Person, Boy, Girl>("People", 1); QQmlEngine engine; QQmlComponent component(&engine, QUrl("qrc:example.qml")); @@ -93,9 +89,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/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 <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); }; 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); }; 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<PieChart>("Charts", 1, 0, "PieChart"); + qmlRegisterTypesAndRevisions<PieChart>("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<PieChart>("Charts", 1, 0, "PieChart"); + qmlRegisterTypesAndRevisions<PieChart>("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<PieChart>("Charts", 1, 0, "PieChart"); + qmlRegisterTypesAndRevisions<PieChart>("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<PieChart>("Charts", 1, 0, "PieChart"); - //![1] - qmlRegisterType<PieSlice>("Charts", 1, 0, "PieSlice"); + qmlRegisterTypesAndRevisions<PieChart, PieSlice>("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<PieChart>("Charts", 1, 0, "PieChart"); - qmlRegisterType<PieSlice>("Charts", 1, 0, "PieSlice"); + qmlRegisterTypesAndRevisions<PieChart, PieSlice>("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<PieSlice> 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<PieChart>(uri, 1, 0, "PieChart"); - qmlRegisterType<PieSlice>(uri, 1, 0, "PieSlice"); + qmlRegisterTypesAndRevisions<PieChart, PieSlice>(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<PieSlice> 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); diff --git a/examples/quick/customitems/maskedmousearea/main.cpp b/examples/quick/customitems/maskedmousearea/main.cpp index 63558d1b20..626f0fd765 100644 --- a/examples/quick/customitems/maskedmousearea/main.cpp +++ b/examples/quick/customitems/maskedmousearea/main.cpp @@ -59,7 +59,7 @@ int main(int argc, char* argv[]) QGuiApplication app(argc,argv); QQuickView view; - qmlRegisterType<MaskedMouseArea>("Example", 1, 0, "MaskedMouseArea"); + qmlRegisterTypesAndRevisions<MaskedMouseArea>("Example", 1); view.setSource(QUrl("qrc:///customitems/maskedmousearea/maskedmousearea.qml")); view.show(); diff --git a/examples/quick/customitems/maskedmousearea/maskedmousearea.h b/examples/quick/customitems/maskedmousearea/maskedmousearea.h index 28ff6ca9df..39d78a019a 100644 --- a/examples/quick/customitems/maskedmousearea/maskedmousearea.h +++ b/examples/quick/customitems/maskedmousearea/maskedmousearea.h @@ -62,6 +62,7 @@ class MaskedMouseArea : public QQuickItem Q_PROPERTY(bool containsMouse READ containsMouse NOTIFY containsMouseChanged) Q_PROPERTY(QUrl maskSource READ maskSource WRITE setMaskSource NOTIFY maskSourceChanged) Q_PROPERTY(qreal alphaThreshold READ alphaThreshold WRITE setAlphaThreshold NOTIFY alphaThresholdChanged) + QML_ELEMENT public: MaskedMouseArea(QQuickItem *parent = 0); diff --git a/examples/quick/customitems/painteditem/TextBalloonPlugin/plugin.h b/examples/quick/customitems/painteditem/TextBalloonPlugin/plugin.h index d3a1f4ba91..41750d1647 100644 --- a/examples/quick/customitems/painteditem/TextBalloonPlugin/plugin.h +++ b/examples/quick/customitems/painteditem/TextBalloonPlugin/plugin.h @@ -59,6 +59,6 @@ class TextBalloonPlugin : public QQmlExtensionPlugin public: void registerTypes(const char *uri) { - qmlRegisterType<TextBalloon>(uri, 1, 0, "TextBalloon"); + qmlRegisterTypesAndRevisions<TextBalloon>(uri, 1); } }; diff --git a/examples/quick/customitems/painteditem/textballoon.h b/examples/quick/customitems/painteditem/textballoon.h index 81b3e2961d..eb72804602 100644 --- a/examples/quick/customitems/painteditem/textballoon.h +++ b/examples/quick/customitems/painteditem/textballoon.h @@ -58,6 +58,7 @@ class TextBalloon : public QQuickPaintedItem { Q_OBJECT Q_PROPERTY(bool rightAligned READ isRightAligned WRITE setRightAligned NOTIFY rightAlignedChanged) + QML_ELEMENT public: TextBalloon(QQuickItem *parent = 0); diff --git a/examples/quick/quickwidgets/qquickviewcomparison/fbitem.h b/examples/quick/quickwidgets/qquickviewcomparison/fbitem.h index 3a4c5a13c2..6270e7adff 100644 --- a/examples/quick/quickwidgets/qquickviewcomparison/fbitem.h +++ b/examples/quick/quickwidgets/qquickviewcomparison/fbitem.h @@ -111,6 +111,7 @@ class FbItem : public QQuickFramebufferObject Q_PROPERTY(QVector3D target READ target WRITE setTarget) Q_PROPERTY(QVector3D rotation READ rotation WRITE setRotation) Q_PROPERTY(bool multisample READ multisample WRITE setMultisample) + QML_ELEMENT public: explicit FbItem(QQuickItem *parent = 0); diff --git a/examples/quick/quickwidgets/qquickviewcomparison/mainwindow.cpp b/examples/quick/quickwidgets/qquickviewcomparison/mainwindow.cpp index 84e116dce6..6ebf36c454 100644 --- a/examples/quick/quickwidgets/qquickviewcomparison/mainwindow.cpp +++ b/examples/quick/quickwidgets/qquickviewcomparison/mainwindow.cpp @@ -86,7 +86,7 @@ MainWindow::MainWindow(bool transparency, bool noRenderAlpha) m_labelStatus = new QLabel; layout->addWidget(m_labelStatus); - qmlRegisterType<FbItem>("fbitem", 1, 0, "FbItem"); + qmlRegisterTypesAndRevisions<FbItem>("fbitem", 1); QWidget *quickContainer = new QWidget; layout->addWidget(quickContainer); diff --git a/examples/quick/quickwidgets/quickwidget/fbitem.h b/examples/quick/quickwidgets/quickwidget/fbitem.h index 7beb9874a5..c1fb866c9a 100644 --- a/examples/quick/quickwidgets/quickwidget/fbitem.h +++ b/examples/quick/quickwidgets/quickwidget/fbitem.h @@ -56,6 +56,7 @@ class FbItem : public QQuickFramebufferObject { Q_OBJECT + QML_ELEMENT public: Renderer *createRenderer() const; }; diff --git a/examples/quick/quickwidgets/quickwidget/main.cpp b/examples/quick/quickwidgets/quickwidget/main.cpp index c54586c5de..541f543f07 100644 --- a/examples/quick/quickwidgets/quickwidget/main.cpp +++ b/examples/quick/quickwidgets/quickwidget/main.cpp @@ -214,7 +214,7 @@ int main(int argc, char **argv) optMultipleSample = parser.isSet(multipleSampleOption); optCoreProfile = parser.isSet(coreProfileOption); - qmlRegisterType<FbItem>("QuickWidgetExample", 1, 0, "FbItem"); + qmlRegisterTypesAndRevisions<FbItem>("QuickWidgetExample", 1); MainWindow mainWindow; mainWindow.show(); diff --git a/examples/quick/scenegraph/customgeometry/beziercurve.h b/examples/quick/scenegraph/customgeometry/beziercurve.h index f2f7832e6d..be9e4ef49f 100644 --- a/examples/quick/scenegraph/customgeometry/beziercurve.h +++ b/examples/quick/scenegraph/customgeometry/beziercurve.h @@ -64,6 +64,7 @@ class BezierCurve : public QQuickItem Q_PROPERTY(QPointF p4 READ p4 WRITE setP4 NOTIFY p4Changed) Q_PROPERTY(int segmentCount READ segmentCount WRITE setSegmentCount NOTIFY segmentCountChanged) + QML_ELEMENT public: BezierCurve(QQuickItem *parent = 0); diff --git a/examples/quick/scenegraph/customgeometry/main.cpp b/examples/quick/scenegraph/customgeometry/main.cpp index 6f3c24e87b..9352e4bd24 100644 --- a/examples/quick/scenegraph/customgeometry/main.cpp +++ b/examples/quick/scenegraph/customgeometry/main.cpp @@ -58,7 +58,7 @@ int main(int argc, char **argv) { QGuiApplication app(argc, argv); - qmlRegisterType<BezierCurve>("CustomGeometry", 1, 0, "BezierCurve"); + qmlRegisterTypesAndRevisions<BezierCurve>("CustomGeometry", 1); QQuickView view; QSurfaceFormat format = view.format(); diff --git a/examples/quick/scenegraph/d3d11underqml/d3d11squircle.h b/examples/quick/scenegraph/d3d11underqml/d3d11squircle.h index be9aadc43b..4be3671d1c 100644 --- a/examples/quick/scenegraph/d3d11underqml/d3d11squircle.h +++ b/examples/quick/scenegraph/d3d11underqml/d3d11squircle.h @@ -59,6 +59,7 @@ class D3D11Squircle : public QQuickItem { Q_OBJECT Q_PROPERTY(qreal t READ t WRITE setT NOTIFY tChanged) + QML_ELEMENT public: D3D11Squircle(); diff --git a/examples/quick/scenegraph/d3d11underqml/main.cpp b/examples/quick/scenegraph/d3d11underqml/main.cpp index d26de1144a..dcab8c879c 100644 --- a/examples/quick/scenegraph/d3d11underqml/main.cpp +++ b/examples/quick/scenegraph/d3d11underqml/main.cpp @@ -56,7 +56,7 @@ int main(int argc, char **argv) { QGuiApplication app(argc, argv); - qmlRegisterType<D3D11Squircle>("D3D11UnderQML", 1, 0, "D3D11Squircle"); + qmlRegisterTypesAndRevisions<D3D11Squircle>("D3D11UnderQML", 1); QQuickWindow::setSceneGraphBackend(QSGRendererInterface::Direct3D11Rhi); diff --git a/examples/quick/scenegraph/fboitem/fboinsgrenderer.h b/examples/quick/scenegraph/fboitem/fboinsgrenderer.h index e1a9ce22c8..1b92b56851 100644 --- a/examples/quick/scenegraph/fboitem/fboinsgrenderer.h +++ b/examples/quick/scenegraph/fboitem/fboinsgrenderer.h @@ -58,6 +58,7 @@ class LogoRenderer; class FboInSGRenderer : public QQuickFramebufferObject { Q_OBJECT + QML_NAMED_ELEMENT(Renderer) public: Renderer *createRenderer() const; }; diff --git a/examples/quick/scenegraph/fboitem/main.cpp b/examples/quick/scenegraph/fboitem/main.cpp index 429224ba95..056bf24ade 100644 --- a/examples/quick/scenegraph/fboitem/main.cpp +++ b/examples/quick/scenegraph/fboitem/main.cpp @@ -58,7 +58,7 @@ int main(int argc, char **argv) { QGuiApplication app(argc, argv); - qmlRegisterType<FboInSGRenderer>("SceneGraphRendering", 1, 0, "Renderer"); + qmlRegisterTypesAndRevisions<FboInSGRenderer>("SceneGraphRendering", 1); QQuickView view; view.setResizeMode(QQuickView::SizeRootObjectToView); diff --git a/examples/quick/scenegraph/graph/graph.h b/examples/quick/scenegraph/graph/graph.h index a1a00cb6dc..e32e657e0e 100644 --- a/examples/quick/scenegraph/graph/graph.h +++ b/examples/quick/scenegraph/graph/graph.h @@ -56,6 +56,7 @@ class Graph : public QQuickItem { Q_OBJECT + QML_ELEMENT public: Graph(); diff --git a/examples/quick/scenegraph/graph/main.cpp b/examples/quick/scenegraph/graph/main.cpp index 2406457ab5..9a575944b9 100644 --- a/examples/quick/scenegraph/graph/main.cpp +++ b/examples/quick/scenegraph/graph/main.cpp @@ -58,7 +58,7 @@ int main(int argc, char *argv[]) { QGuiApplication a(argc, argv); - qmlRegisterType<Graph>("Graph", 1, 0, "Graph"); + qmlRegisterTypesAndRevisions<Graph>("Graph", 1); QQuickView view; view.resize(800, 400); diff --git a/examples/quick/scenegraph/metalunderqml/main.cpp b/examples/quick/scenegraph/metalunderqml/main.cpp index 5ad337abb1..3e620137cd 100644 --- a/examples/quick/scenegraph/metalunderqml/main.cpp +++ b/examples/quick/scenegraph/metalunderqml/main.cpp @@ -56,7 +56,7 @@ int main(int argc, char **argv) { QGuiApplication app(argc, argv); - qmlRegisterType<MetalSquircle>("MetalUnderQML", 1, 0, "MetalSquircle"); + qmlRegisterTypesAndRevisions<MetalSquircle>("MetalUnderQML", 1); QQuickWindow::setSceneGraphBackend(QSGRendererInterface::MetalRhi); diff --git a/examples/quick/scenegraph/metalunderqml/metalsquircle.h b/examples/quick/scenegraph/metalunderqml/metalsquircle.h index 43c4afad21..18db7d45f3 100644 --- a/examples/quick/scenegraph/metalunderqml/metalsquircle.h +++ b/examples/quick/scenegraph/metalunderqml/metalsquircle.h @@ -59,6 +59,7 @@ class MetalSquircle : public QQuickItem { Q_OBJECT Q_PROPERTY(qreal t READ t WRITE setT NOTIFY tChanged) + QML_ELEMENT public: MetalSquircle(); diff --git a/examples/quick/scenegraph/openglunderqml/main.cpp b/examples/quick/scenegraph/openglunderqml/main.cpp index 022d6a75bb..c04d0da68f 100644 --- a/examples/quick/scenegraph/openglunderqml/main.cpp +++ b/examples/quick/scenegraph/openglunderqml/main.cpp @@ -59,7 +59,7 @@ int main(int argc, char **argv) { QGuiApplication app(argc, argv); - qmlRegisterType<Squircle>("OpenGLUnderQML", 1, 0, "Squircle"); + qmlRegisterTypesAndRevisions<Squircle>("OpenGLUnderQML", 1); QQuickView view; view.setResizeMode(QQuickView::SizeRootObjectToView); diff --git a/examples/quick/scenegraph/openglunderqml/squircle.h b/examples/quick/scenegraph/openglunderqml/squircle.h index 1b9995bc1e..c24fdd50c2 100644 --- a/examples/quick/scenegraph/openglunderqml/squircle.h +++ b/examples/quick/scenegraph/openglunderqml/squircle.h @@ -86,6 +86,7 @@ class Squircle : public QQuickItem { Q_OBJECT Q_PROPERTY(qreal t READ t WRITE setT NOTIFY tChanged) + QML_ELEMENT public: Squircle(); diff --git a/examples/quick/scenegraph/rendernode/customrenderitem.h b/examples/quick/scenegraph/rendernode/customrenderitem.h index a0ac3468e4..74115b2505 100644 --- a/examples/quick/scenegraph/rendernode/customrenderitem.h +++ b/examples/quick/scenegraph/rendernode/customrenderitem.h @@ -56,6 +56,7 @@ class CustomRenderItem : public QQuickItem { Q_OBJECT + QML_ELEMENT public: CustomRenderItem(QQuickItem *parent = nullptr); diff --git a/examples/quick/scenegraph/rendernode/main.cpp b/examples/quick/scenegraph/rendernode/main.cpp index 146d787e50..b1dfe47829 100644 --- a/examples/quick/scenegraph/rendernode/main.cpp +++ b/examples/quick/scenegraph/rendernode/main.cpp @@ -59,7 +59,7 @@ int main(int argc, char **argv) QGuiApplication app(argc, argv); //! [1] - qmlRegisterType<CustomRenderItem>("SceneGraphRendering", 2, 0, "CustomRenderItem"); + qmlRegisterTypesAndRevisions<CustomRenderItem>("SceneGraphRendering", 2); //! [1] QQuickView view; diff --git a/examples/quick/scenegraph/simplematerial/simplematerial.cpp b/examples/quick/scenegraph/simplematerial/simplematerial.cpp index 6773b6fb5a..55e1d879ca 100644 --- a/examples/quick/scenegraph/simplematerial/simplematerial.cpp +++ b/examples/quick/scenegraph/simplematerial/simplematerial.cpp @@ -157,6 +157,7 @@ class Item : public QQuickItem Q_OBJECT Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) + QML_NAMED_ELEMENT(SimpleMaterialItem) public: @@ -203,7 +204,7 @@ int main(int argc, char **argv) { QGuiApplication app(argc, argv); - qmlRegisterType<Item>("SimpleMaterial", 1, 0, "SimpleMaterialItem"); + qmlRegisterTypesAndRevisions<Item>("SimpleMaterial", 1); QQuickView view; view.setResizeMode(QQuickView::SizeRootObjectToView); diff --git a/examples/quick/scenegraph/textureinthread/main.cpp b/examples/quick/scenegraph/textureinthread/main.cpp index 7a46f25390..7c22fa7fdf 100644 --- a/examples/quick/scenegraph/textureinthread/main.cpp +++ b/examples/quick/scenegraph/textureinthread/main.cpp @@ -70,7 +70,7 @@ int main(int argc, char **argv) return app.exec(); } - qmlRegisterType<ThreadRenderer>("SceneGraphRendering", 1, 0, "Renderer"); + qmlRegisterTypesAndRevisions<ThreadRenderer>("SceneGraphRendering", 1); int execReturn = 0; { diff --git a/examples/quick/scenegraph/textureinthread/threadrenderer.h b/examples/quick/scenegraph/textureinthread/threadrenderer.h index 8442041bf8..96c00e7b2e 100644 --- a/examples/quick/scenegraph/textureinthread/threadrenderer.h +++ b/examples/quick/scenegraph/textureinthread/threadrenderer.h @@ -58,6 +58,7 @@ class RenderThread; class ThreadRenderer : public QQuickItem { Q_OBJECT + QML_NAMED_ELEMENT(Renderer) public: ThreadRenderer(); diff --git a/examples/quick/scenegraph/threadedanimation/main.cpp b/examples/quick/scenegraph/threadedanimation/main.cpp index b1b0c05085..c77a291f5d 100644 --- a/examples/quick/scenegraph/threadedanimation/main.cpp +++ b/examples/quick/scenegraph/threadedanimation/main.cpp @@ -57,7 +57,7 @@ int main(int argc, char **argv) { QGuiApplication app(argc, argv); - qmlRegisterType<Spinner>("Spinner", 1, 0, "Spinner"); + qmlRegisterTypesAndRevisions<Spinner>("Spinner", 1); QQuickView view; view.setSource(QUrl("qrc:///scenegraph/threadedanimation/main.qml")); diff --git a/examples/quick/scenegraph/threadedanimation/spinner.h b/examples/quick/scenegraph/threadedanimation/spinner.h index c3f3394c93..fd3eaa7751 100644 --- a/examples/quick/scenegraph/threadedanimation/spinner.h +++ b/examples/quick/scenegraph/threadedanimation/spinner.h @@ -58,6 +58,7 @@ class Spinner : public QQuickItem Q_OBJECT Q_PROPERTY(bool spinning READ spinning WRITE setSpinning NOTIFY spinningChanged) + QML_ELEMENT public: Spinner(); diff --git a/examples/quick/scenegraph/twotextureproviders/main.cpp b/examples/quick/scenegraph/twotextureproviders/main.cpp index a5d23b6adc..3f53bb6e32 100644 --- a/examples/quick/scenegraph/twotextureproviders/main.cpp +++ b/examples/quick/scenegraph/twotextureproviders/main.cpp @@ -58,7 +58,7 @@ int main(int argc, char **argv) { QGuiApplication app(argc, argv); - qmlRegisterType<XorBlender>("SceneGraphRendering", 1, 0, "XorBlender"); + qmlRegisterTypesAndRevisions<XorBlender>("SceneGraphRendering", 1); QQuickView view; view.setResizeMode(QQuickView::SizeRootObjectToView); diff --git a/examples/quick/scenegraph/twotextureproviders/xorblender.h b/examples/quick/scenegraph/twotextureproviders/xorblender.h index 94132f09fb..17557b8efd 100644 --- a/examples/quick/scenegraph/twotextureproviders/xorblender.h +++ b/examples/quick/scenegraph/twotextureproviders/xorblender.h @@ -58,6 +58,7 @@ class XorBlender : public QQuickItem Q_OBJECT Q_PROPERTY(QQuickItem *source1 READ source1 WRITE setSource1 NOTIFY source1Changed) Q_PROPERTY(QQuickItem *source2 READ source2 WRITE setSource2 NOTIFY source2Changed) + QML_ELEMENT public: explicit XorBlender(QQuickItem *parent = 0); diff --git a/examples/quick/tableview/gameoflife/gameoflifemodel.h b/examples/quick/tableview/gameoflife/gameoflifemodel.h index 3ea1469861..161e0b2cfc 100644 --- a/examples/quick/tableview/gameoflife/gameoflifemodel.h +++ b/examples/quick/tableview/gameoflife/gameoflifemodel.h @@ -54,11 +54,13 @@ #include <array> #include <QAbstractTableModel> #include <QPoint> +#include <QtQml/qqml.h> //! [modelclass] class GameOfLifeModel : public QAbstractTableModel { Q_OBJECT + QML_ELEMENT Q_ENUMS(Roles) public: diff --git a/examples/quick/tableview/gameoflife/main.cpp b/examples/quick/tableview/gameoflife/main.cpp index 5101880b06..fcea7080ea 100644 --- a/examples/quick/tableview/gameoflife/main.cpp +++ b/examples/quick/tableview/gameoflife/main.cpp @@ -59,7 +59,7 @@ int main(int argc, char *argv[]) QQmlApplicationEngine engine; //! [registertype] - qmlRegisterType<GameOfLifeModel>("GameOfLifeModel", 1, 0, "GameOfLifeModel"); + qmlRegisterTypesAndRevisions<GameOfLifeModel>("GameOfLifeModel", 1); //! [registertype] engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); diff --git a/examples/quick/tableview/pixelator/imagemodel.h b/examples/quick/tableview/pixelator/imagemodel.h index bf0ec90da4..de8ad7cd8d 100644 --- a/examples/quick/tableview/pixelator/imagemodel.h +++ b/examples/quick/tableview/pixelator/imagemodel.h @@ -53,12 +53,14 @@ #include <QAbstractTableModel> #include <QImage> +#include <QtQml/qqml.h> //! [model] class ImageModel : public QAbstractTableModel { Q_OBJECT Q_PROPERTY(QString source READ source WRITE setSource NOTIFY sourceChanged) + QML_ELEMENT public: ImageModel(QObject *parent = nullptr); diff --git a/examples/quick/tableview/pixelator/main.cpp b/examples/quick/tableview/pixelator/main.cpp index c57039556a..a8cb6c4e86 100644 --- a/examples/quick/tableview/pixelator/main.cpp +++ b/examples/quick/tableview/pixelator/main.cpp @@ -60,7 +60,7 @@ int main(int argc, char *argv[]) QQmlApplicationEngine engine; //! [registertype] - qmlRegisterType<ImageModel>("ImageModel", 1, 0, "ImageModel"); + qmlRegisterTypesAndRevisions<ImageModel>("ImageModel", 1); //! [registertype] engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); |