aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/doc/extras/QtQml.qmlRegisterSingletonType.rst
blob: 83102bf8645a001e0ef9660f54d865b840452102 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
.. currentmodule:: PySide6.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.