aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/doc/extras/QtQml.QmlElement.rst
blob: b567bb3ccd0a3753f120dc2e81deb302b157dbf6 (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
.. currentmodule:: PySide6.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 {
         // ...
      }