aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/doc/extras
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2022-01-27 14:38:43 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2022-02-16 21:14:05 +0100
commitabb6e8ca90fb2ff0718f7e29d00ebd90bc9f7ccd (patch)
tree29028d7346e0dd19a2598c7aeaffe13af1fc2487 /sources/pyside6/doc/extras
parenta54272ecfa6ce69e201a72678da26f7f92238ac5 (diff)
Add the QmlAttached decorator
[ChangeLog][PySide6] The QmlAttached decorator has been added. Task-number: PYSIDE-1709 Change-Id: I0301ecc7a9bc7a1b798095e8972b2fe4addf2eaf Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/pyside6/doc/extras')
-rw-r--r--sources/pyside6/doc/extras/QtQml.QmlAttached.rst40
1 files changed, 40 insertions, 0 deletions
diff --git a/sources/pyside6/doc/extras/QtQml.QmlAttached.rst b/sources/pyside6/doc/extras/QtQml.QmlAttached.rst
new file mode 100644
index 000000000..e3fefb6b2
--- /dev/null
+++ b/sources/pyside6/doc/extras/QtQml.QmlAttached.rst
@@ -0,0 +1,40 @@
+.. currentmodule:: PySide6.QtQml
+.. _QmlAttached:
+
+QmlAttached
+***********
+
+.. py:decorator:: QmlAttached
+
+This decorator declares that the enclosing type attaches the type passed as
+an attached property to other types. 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
+
+ @QmlAnonymous
+ class LayoutAttached(QObject):
+ @Property(QMargins)
+ def margins(self):
+ ...
+
+ @QmlElement()
+ @QmlAttached(LayoutAttached)
+ class Layout(QObject):
+ ...
+
+Afterwards the class may be used in QML:
+
+.. code-block:: javascript
+
+ import com.library.name 1.0
+
+ Layout {
+ Widget {
+ Layout.margins: [2, 2, 2, 2]
+ }
+ }