aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/doc/extras/QtQml.QmlExtended.rst
blob: af113a9c80479c0aa4f0f92464a2a38c9657ffb1 (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
29
30
31
32
.. currentmodule:: PySide6.QtQml
.. py:decorator:: QmlExtended

Declares that the enclosing type uses the type passed as an extension to
provide further properties, methods, and enumerations in QML. This takes effect
if the type is exposed to QML using a ``QmlElement()`` or ``QmlNamedElement()``
decorator.

.. code-block:: python

    QML_IMPORT_NAME = "com.library.name"
    QML_IMPORT_MAJOR_VERSION = 1
    QML_IMPORT_MINOR_VERSION = 0 # Optional

    class LineEditExtension(QObject):
        pass

    @QmlNamedElement("QLineEdit")
    @QmlExtended(LineEditExtension)
    @QmlForeign(QLineEdit)
    class LineEditForeign(QObject):
        ...

Afterwards the class may be used in QML:

.. code-block:: javascript

      import com.library.name 1.0

      QLineEdit {
          left_margin: 10
      }