aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/doc
diff options
context:
space:
mode:
authorMaximilian Goldstein <max.goldstein@qt.io>2020-08-27 15:45:56 +0200
committerMaximilian Goldstein <max.goldstein@qt.io>2020-10-22 11:53:25 +0000
commit7c448f5c27a51a60e27a54b79e298b53312ef2a8 (patch)
tree8b3175f6bb84c9a2868d50905ffd25ac7f85f0ab /sources/pyside2/doc
parent9614cb5e47e863f036f19ac3f818253dd69bb828 (diff)
QtQml: Implement QmlElement
Equivalent to QML_ELEMENT in C++, this enables users to register classes for use in QML by using the QmlElement decorator. Change-Id: I697e486ef58b18cce4c310e4b556e28735a16d45 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/pyside2/doc')
-rw-r--r--sources/pyside2/doc/extras/QtQml.QmlElement.rst28
1 files changed, 28 insertions, 0 deletions
diff --git a/sources/pyside2/doc/extras/QtQml.QmlElement.rst b/sources/pyside2/doc/extras/QtQml.QmlElement.rst
new file mode 100644
index 000000000..90a5134c1
--- /dev/null
+++ b/sources/pyside2/doc/extras/QtQml.QmlElement.rst
@@ -0,0 +1,28 @@
+.. currentmodule:: PySide2.QtQml
+.. _QmlElement:
+
+QmlElement
+**********
+
+.. py:decorator:: QmlElement
+
+ This decorator registers a class it is attached to for use in QML, using
+ global variables to specify the import name and version.
+
+ ::
+ QML_IMPORT_NAME = "com.library.name"
+ QML_IMPORT_MAJOR_VERSION = 1
+ QML_IMPORT_MINOR_VERSION = 0 # Optional
+
+ @QmlElement
+ class ClassForQml(QObject):
+ # ...
+
+ Afterwards the class may be used in QML:
+
+ ::
+ import com.library.name 1.0
+
+ ClassForQml {
+ // ...
+ }