diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2022-11-22 11:35:25 +0100 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2022-12-02 16:55:21 +0100 |
commit | 3f4856dbca0114b8f354df482fec437dc6b04d23 (patch) | |
tree | 7f3b6542f20c2c331a21e395a3937db30b507a8d /src/qml/qml/qqmlapplicationengine.h | |
parent | 90da0220e77cb6d71df460bd0e30358d734346d1 (diff) |
Introduce QQmlApplicationEngine::loadFromModule
This allow instantiating QML types via their module and typename. It
simply exposes the underlying functionality of
QQmlComponent::loadFromModule.
Also add the corresponding convenience constructor.
This commit also does some minor refactoring so that functionality can
be shared between load and loadFromModule.
[ChangeLog][QtQml][QQmlApplicationEngine] It is now possible to load QML
types via their module and type name.
Fixes: QTBUG-97156
Change-Id: Iee812db269d27e4db4b10117ed2570272a7cc40c
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlapplicationengine.h')
-rw-r--r-- | src/qml/qml/qqmlapplicationengine.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlapplicationengine.h b/src/qml/qml/qqmlapplicationengine.h index 828629602e..afbb76dd06 100644 --- a/src/qml/qml/qqmlapplicationengine.h +++ b/src/qml/qml/qqmlapplicationengine.h @@ -19,6 +19,7 @@ class Q_QML_EXPORT QQmlApplicationEngine : public QQmlEngine public: QQmlApplicationEngine(QObject *parent = nullptr); QQmlApplicationEngine(const QUrl &url, QObject *parent = nullptr); + QQmlApplicationEngine(QAnyStringView uri, QAnyStringView typeName, QObject *parent = nullptr); QQmlApplicationEngine(const QString &filePath, QObject *parent = nullptr); ~QQmlApplicationEngine() override; @@ -27,6 +28,7 @@ public: public Q_SLOTS: void load(const QUrl &url); void load(const QString &filePath); + void loadFromModule(QAnyStringView uri, QAnyStringView typeName); void setInitialProperties(const QVariantMap &initialProperties); void setExtraFileSelectors(const QStringList &extraFileSelectors); void loadData(const QByteArray &data, const QUrl &url = QUrl()); |