aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/doc/extras/QtQml.QmlForeign.rst
blob: 343318b9ae3e2371a76a7fc3dc575cd3598f754c (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
PySide6.QtQml.QmlForeign
========================

.. currentmodule:: PySide6.QtQml
.. py:decorator:: QmlForeign

    This decorator can be used to change the type that is created by QML.

    This is useful for registering types that cannot be amended by adding the
    :deco:`QmlElement` decorator, for example because they belong to 3rdparty libraries.

    .. code-block:: python

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

        @QmlNamedElement("QWidget")
        @QmlForeign(QWidget)
        class ForeignWidgetHelperClass(QObject):
              ...

    Afterwards the class may be used in QML:

    .. code-block:: javascript

        import com.library.name 1.0

        QWidget {
            // ...
        }