qmlRegisterSingletonType#

qmlRegisterSingletonType(pytype: type, uri: str, versionMajor: int, versionMinor: int, typeName: str) int#
Parameters:
  • pytype (type) – Python class

  • uri (str) – uri to use while importing the component in QML

  • versionMajor (int) – major version

  • versionMinor (int) – minor version

  • typeName (str) – name exposed to QML

Returns:

int (the QML type id)

This function registers a Python type as a singleton in the QML system.

Alternatively, the QmlSingleton decorator decorator can be used.

qmlRegisterSingletonType(pytype: type, uri: str, versionMajor: int, versionMinor: int, typeName: str, callback: object) int#
Parameters:
  • pytype (type) – Python class

  • uri (str) – uri to use while importing the component in QML

  • versionMajor (int) – major version

  • versionMinor (int) – minor version

  • typeName (str) – name exposed to QML

  • callback (object) – Python callable (to handle Python type)

Returns:

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.

qmlRegisterSingletonType(uri: str, versionMajor: int, versionMinor: int, typeName: str, callback: object) int#
Parameters:
  • uri (str) – uri to use while importing the component in QML

  • versionMajor (int) – major version

  • versionMinor (int) – minor version

  • typeName (str) – name exposed to QML

  • callback (object) – Python callable (to handle QJSValue)

Returns:

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.