qmlRegisterUncreatableType(pytype: type, uri: str, versionMajor: int, versionMinor: int, qmlName: str, noCreationReason: str) → int¶
pytype (type) – Python class
uri (str) – uri to use while importing the component in QML
versionMajor (int) – major version
versionMinor (int) – minor version
qmlName (str) – name exposed to QML
noCreationReason (str) – Error message shown when trying to create the QML type
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.
© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.