diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2019-08-21 18:34:21 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2019-09-26 12:32:17 +0200 |
commit | cc1a604c704f848927b3fa0a97b0a50b0b79d2a4 (patch) | |
tree | 610ece713eba021c8e5a3d248f54a62370e810f8 /tools/qml | |
parent | 531cf90305ae50920b2e597dd0758fdb82ad88b0 (diff) |
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 <fabian.kosmale@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tools/qml')
-rw-r--r-- | tools/qml/conf.h | 3 | ||||
-rw-r--r-- | tools/qml/main.cpp | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/tools/qml/conf.h b/tools/qml/conf.h index 0c9d8613a0..e83d63cba5 100644 --- a/tools/qml/conf.h +++ b/tools/qml/conf.h @@ -30,6 +30,7 @@ #include <QtQml/QQmlContext> #include <QtQml/QQmlListProperty> +#include <QtQml/qqml.h> #include <QObject> #include <QUrl> @@ -38,6 +39,7 @@ class PartialScene : public QObject Q_OBJECT Q_PROPERTY(QUrl container READ container WRITE setContainer NOTIFY containerChanged) Q_PROPERTY(QString itemType READ itemType WRITE setItemType NOTIFY itemTypeChanged) + QML_ELEMENT public: PartialScene(QObject *parent = 0) : QObject(parent) {} @@ -72,6 +74,7 @@ class Config : public QObject Q_OBJECT Q_PROPERTY(QQmlListProperty<PartialScene> sceneCompleters READ sceneCompleters) Q_CLASSINFO("DefaultProperty", "sceneCompleters") + QML_NAMED_ELEMENT(Configuration) public: Config (QObject* parent=0) : QObject(parent) {} diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp index 9edc90e050..a57b2c0db2 100644 --- a/tools/qml/main.cpp +++ b/tools/qml/main.cpp @@ -423,8 +423,7 @@ int main(int argc, char *argv[]) app->setOrganizationDomain("qt-project.org"); QCoreApplication::setApplicationVersion(QLatin1String(QT_VERSION_STR)); - qmlRegisterType<Config>("QmlRuntime.Config", 1, 0, "Configuration"); - qmlRegisterType<PartialScene>("QmlRuntime.Config", 1, 0, "PartialScene"); + qmlRegisterTypesAndRevisions<Config, PartialScene>("QmlRuntime.Config", 1); QQmlApplicationEngine e; QStringList files; QString confFile; |