diff options
author | Maximilian Goldstein <max.goldstein@qt.io> | 2020-07-24 12:37:30 +0200 |
---|---|---|
committer | Maximilian Goldstein <max.goldstein@qt.io> | 2020-07-24 12:36:49 +0000 |
commit | 8ead3d8468fda9fd9eb42b997686bfa0a66f6d00 (patch) | |
tree | df631c3634a48fb4f6ebfb11eabb53320a84b4ab /sources/pyside2/doc | |
parent | d8427f681deadc64eae3506d0bc2aad5cdb6b79f (diff) |
doc: Add docs for qmlRegisterUncreatableType
Change-Id: I8d46f4f6b82639b417a146a81f84888ce363d5d4
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/pyside2/doc')
-rw-r--r-- | sources/pyside2/doc/extras/QtQml.qmlRegisterUncreatableType.rst | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/sources/pyside2/doc/extras/QtQml.qmlRegisterUncreatableType.rst b/sources/pyside2/doc/extras/QtQml.qmlRegisterUncreatableType.rst new file mode 100644 index 000000000..0e73f3d97 --- /dev/null +++ b/sources/pyside2/doc/extras/QtQml.qmlRegisterUncreatableType.rst @@ -0,0 +1,36 @@ +.. currentmodule:: PySide2.QtQml +.. _qmlRegisterUncreatableType: + + +qmlRegisterUncreatableType +************************** + + +.. py:function:: qmlRegisterUncreatableType(pytype: type, uri: str, versionMajor: int, versionMinor: int, qmlName: str, noCreationReason: 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 + :param str noCreationReason: Error message shown when trying to create the QML type + :return: int (the QML type id) + + This function registers the Python *type* in the QML system as an uncreatable type with the + name *qmlName*, in the library imported from *uri* having the + version number composed from *versionMajor* and *versionMinor*, + showing *noCreationReason* as an error message when creating the type is attempted. + + 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': + + :: + qmlRegisterUncreatableType(MySliderItem, "com.mycompany.qmlcomponents", 1, 0, "Slider", "Slider cannot be created.") + + 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. |