aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/doc
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-11-02 10:57:59 +0100
committerUlf Hermann <ulf.hermann@qt.io>2020-11-02 14:00:23 +0100
commite826636a0bebd0d73e6c17038b24ee2a42d92ead (patch)
tree0a2ea355eb83af6ac636bec0e5fb0028b81ffbe2 /src/qml/doc
parent6f968781c4c8a278a7743b0904fb2bdf4c6ddf1a (diff)
QML: Allow singletons to be created with a factory function
This is in line with what we do on qmlRegisterSingletonType(), and it allows us to return singleton objects created independently of the instantiation mechanism. Change-Id: Ia6a077f5d22241593acd8cc87b3f65ae20f95667 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Diffstat (limited to 'src/qml/doc')
-rw-r--r--src/qml/doc/src/qmlfunctions.qdoc14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/qml/doc/src/qmlfunctions.qdoc b/src/qml/doc/src/qmlfunctions.qdoc
index caca58f34a..25cdd8142a 100644
--- a/src/qml/doc/src/qmlfunctions.qdoc
+++ b/src/qml/doc/src/qmlfunctions.qdoc
@@ -163,12 +163,14 @@
Declares the enclosing type to be a singleton in QML. This only takes effect
if the type is available in QML, by having a \l QML_ELEMENT or
\l QML_NAMED_ELEMENT() macro. By default, each QQmlEngine will try to create a
- singleton instance using the type's default constructor when the type is first
- accessed. If there is no default constructor the singleton is initially
- inaccessible. This behavior can be overridden by calling
- \l qmlRegisterSingletonType() with a specific factory function or
- \l qmlRegisterSingletonInstance() with a specific instance for the same class
- and the same type namespace and version.
+ singleton instance using either the type's default constructor or a static
+ factory function of the signature \a{T *create(QQmlEngine *, QJSEngine *)}
+ when the type is first accessed. If both do exist and are accessible, the
+ default constructor is preferred. If there is no default constructor and no
+ factory function the singleton is initially inaccessible. This behavior can be
+ overridden by calling \l qmlRegisterSingletonType() with a specific (external)
+ factory function or \l qmlRegisterSingletonInstance() with a specific instance
+ for the same class and the same type namespace and version.
\sa QML_ELEMENT, QML_NAMED_ELEMENT(), qmlRegisterSingletonInstance().
*/