aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/doc
diff options
context:
space:
mode:
authorCristian Maureira-Fredes <Cristian.Maureira-Fredes@qt.io>2020-07-24 09:24:15 +0200
committerCristian Maureira-Fredes <cristian.maureira-fredes@qt.io>2020-07-24 10:29:16 +0000
commitd8427f681deadc64eae3506d0bc2aad5cdb6b79f (patch)
tree0f8978e1a3d24f0b861532c11712173cd05e204a /sources/pyside2/doc
parentcc91eb893e53ea2516d895bd1861c1159d5a5c90 (diff)
doc: add qmlRegisterType and qmlRegisterSingletonType
when the inject-documentation tag is used inside a namespace or module instead of class, it does not properly work. With this workaround, the data will be rendered on the online/offline documentation. Task-number: PYSIDE-691 Change-Id: I832f43cb1ffba9294a2e282ba002ce4aff07e253 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/pyside2/doc')
-rw-r--r--sources/pyside2/doc/extras/QtQml.qmlRegisterSingletonType.rst44
-rw-r--r--sources/pyside2/doc/extras/QtQml.qmlRegisterType.rst41
2 files changed, 85 insertions, 0 deletions
diff --git a/sources/pyside2/doc/extras/QtQml.qmlRegisterSingletonType.rst b/sources/pyside2/doc/extras/QtQml.qmlRegisterSingletonType.rst
new file mode 100644
index 000000000..2e0f80762
--- /dev/null
+++ b/sources/pyside2/doc/extras/QtQml.qmlRegisterSingletonType.rst
@@ -0,0 +1,44 @@
+.. currentmodule:: PySide2.QtQml
+.. _qmlRegisterSingletonType:
+
+qmlRegisterSingletonType
+************************
+
+.. py:function:: qmlRegisterSingletonType(pytype: type, uri: str, versionMajor: int, versionMinor: int, typeName: str) -> int
+
+ :param type pytype: Python class
+ :param str uri: uri to use while importing the component in QML
+ :param int versionMajor: major version
+ :param int versionMinor: minor version
+ :param str typeName: name exposed to QML
+ :return: int (the QML type id)
+
+ This function registers a Python type as a singleton in the QML system.
+
+.. py:function:: qmlRegisterSingletonType(pytype: type, uri: str, versionMajor: int, versionMinor: int, typeName: str, callback: object) -> int
+
+ :param type pytype: Python class
+ :param str uri: uri to use while importing the component in QML
+ :param int versionMajor: major version
+ :param int versionMinor: minor version
+ :param str typeName: name exposed to QML
+ :param object callback: Python callable (to handle Python type)
+ :return: int (the QML type id)
+
+ This function registers a Python type as a singleton in the QML system using
+ the provided callback (which gets a QQmlEngine as a parameter) to generate
+ the singleton.
+
+
+.. py:function:: qmlRegisterSingletonType(uri: str, versionMajor: int, versionMinor: int, typeName: str, callback: object) -> int
+
+ :param str uri: uri to use while importing the component in QML
+ :param int versionMajor: major version
+ :param int versionMinor: minor version
+ :param str typeName: name exposed to QML
+ :param object callback: Python callable (to handle QJSValue)
+ :return: int (the QML type id)
+
+ This function registers a QJSValue as a singleton in the QML system using
+ the provided callback (which gets a QQmlEngine as a parameter) to
+ generate the singleton.
diff --git a/sources/pyside2/doc/extras/QtQml.qmlRegisterType.rst b/sources/pyside2/doc/extras/QtQml.qmlRegisterType.rst
new file mode 100644
index 000000000..d8bd3acb1
--- /dev/null
+++ b/sources/pyside2/doc/extras/QtQml.qmlRegisterType.rst
@@ -0,0 +1,41 @@
+.. currentmodule:: PySide2.QtQml
+.. _qmlRegisterType:
+
+qmlRegisterType
+***************
+
+.. py:function:: qmlRegisterType(pytype: type, uri: str, versionMajor: int, versionMinor: int, qmlName: str) -> int
+
+ :param type pytype: Python class
+ :param str uri: uri to use while importing the component in QML
+ :param int versionMajor: major version
+ :param int versionMinor: minor version
+ :param str qmlName: name exposed to QML
+ :return: int (the QML type id)
+
+ This function registers the Python *type* in the QML system with the
+ name *qmlName*, in the library imported from *uri* having the
+ version number composed from *versionMajor* and *versionMinor*.
+
+ For example, this registers a Python class 'MySliderItem' as a QML
+ type named 'Slider' for version '1.0' of a module called
+ 'com.mycompany.qmlcomponents':
+
+ ::
+
+ qmlRegisterType(MySliderItem, "com.mycompany.qmlcomponents", 1, 0, "Slider")
+
+ Once this is registered, the type can be used in QML by importing
+ the specified module name and version number:
+
+ ::
+
+ import com.mycompany.qmlcomponents 1.0
+
+ Slider { ... }
+
+ Note that it's perfectly reasonable for a library to register types
+ to older versions than the actual version of the library.
+ Indeed, it is normal for the new library to allow QML written to
+ previous versions to continue to work, even if more advanced
+ versions of some of its types are available.