diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2022-12-06 13:28:48 +0100 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2022-12-08 15:48:34 +0100 |
commit | e43638c8a830b9ade737b361fa471381b3afdb11 (patch) | |
tree | f693d837b8631357f6bf9e987c09ec846a8b536e /src/qml/doc/snippets | |
parent | c3ebe3ff3b8fb2c5a3f97bcb83fb594246bc8130 (diff) |
QQmlEngine: Add module + type based singletonInstance overload
This makes it consistent with QQmlComponent::loadFromModule. It also
avoids the issue the qmlTypeId does currently only work if the module
has been imported; though that will be fixed in a separate commit.
Change-Id: Id284f7ed2de7af461b782c5b5d71d9bfc0039844
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Diffstat (limited to 'src/qml/doc/snippets')
-rw-r--r-- | src/qml/doc/snippets/code/src_qml_qqmlengine.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/qml/doc/snippets/code/src_qml_qqmlengine.cpp b/src/qml/doc/snippets/code/src_qml_qqmlengine.cpp index 7057718b52..ff4cf634a0 100644 --- a/src/qml/doc/snippets/code/src_qml_qqmlengine.cpp +++ b/src/qml/doc/snippets/code/src_qml_qqmlengine.cpp @@ -42,3 +42,10 @@ void wrapper4(int typeId) { QJSValue instance = engine.singletonInstance<QJSValue>(typeId); //! [4] } + +void wrapper5() { +///! [5] + QQmlEngine engine; + MySingleton *singleton = engine.singletonInstance<MySingleton *>("mymodule", "MySingleton"); +///! [5] +} |