aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/doc/extras/QtQml.QmlExtended.rst
blob: eaeb77d1c0e9a6cb313c78fd25890769ebfb8c61 (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
33
34
35
PySide6.QtQml.QmlExtended
=========================

.. 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 :deco:`QmlElement` or :deco:`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
          }