From e43638c8a830b9ade737b361fa471381b3afdb11 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Tue, 6 Dec 2022 13:28:48 +0100 Subject: 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 --- src/qml/doc/snippets/code/src_qml_qqmlengine.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/qml/doc/snippets') 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(typeId); //! [4] } + +void wrapper5() { +///! [5] + QQmlEngine engine; + MySingleton *singleton = engine.singletonInstance("mymodule", "MySingleton"); +///! [5] +} -- cgit v1.2.3