diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2020-04-17 12:13:25 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2020-06-09 08:01:03 +0200 |
commit | 9752ad5af7c7ae188250ab5b8b65c74f70d57b41 (patch) | |
tree | 19c1b9a8ed6444b626bba339679e1788562e6569 /src/qml/qml/qqml.cpp | |
parent | 1d510acc29dd2cebfb72364b8b933287f54c5579 (diff) |
Add methods to programatically insert qmldir import statements
We need this for controls2 to select the style at runtime.
Change-Id: I23b6ab962a647b519d5af019eade27f89e1e4e00
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/qml/qqml.cpp')
-rw-r--r-- | src/qml/qml/qqml.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/qml/qml/qqml.cpp b/src/qml/qml/qqml.cpp index a57daf78d2..b342690c39 100644 --- a/src/qml/qml/qqml.cpp +++ b/src/qml/qml/qqml.cpp @@ -72,6 +72,37 @@ void qmlRegisterModule(const char *uri, int versionMajor, int versionMinor) QQmlMetaType::registerModule(uri, QTypeRevision::fromVersion(versionMajor, versionMinor)); } +/*! + * Registers an implicit import for module \a uri of major version \a majorVersion + * + * This has the same effect as an \c import statement in a qmldir file: Whenever + * \a uri version \a majorVersion is imported, \a import is automatically + * imported, too, with the same version. + * + * \sa qmlUnregisterModuleImport() + */ +void qmlRegisterModuleImport(const char *uri, int majorVersion, const char *import) +{ + QQmlMetaType::registerModuleImport( + QString::fromUtf8(uri), QTypeRevision::fromMajorVersion(majorVersion), + QString::fromUtf8(import)); +} + +/*! + * Removes a module import previously registered with qmlRegisterModuleImport() + * + * Calling this function makes sure that \a import is not automatically imported + * anymore when \a uri of version \a majorVersion is. + * + * \sa qmlRegisterModuleImport() + */ +void qmlUnregisterModuleImport(const char *uri, int majorVersion, const char *import) +{ + QQmlMetaType::unregisterModuleImport( + QString::fromUtf8(uri), QTypeRevision::fromMajorVersion(majorVersion), + QString::fromUtf8(import)); +} + //From qqml.h int qmlTypeId(const char *uri, int versionMajor, int versionMinor, const char *qmlName) { |