From 9e0da8e0288d4c87eaa6f8a22ec107e04d0cd305 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 28 Apr 2023 16:46:23 +0200 Subject: Move the QML reference examples around to match the structure in Qt Adapt the tests accordingly. Task-number: PYSIDE-2206 Task-number: QTBUG-111033 Pick-to: 6.5 Change-Id: I332d6467da56b88ecbf9282d23092d8d47b730e0 Reviewed-by: Qt CI Bot Reviewed-by: Shyamnath Premnadh --- .../qml/referenceexamples/adding/doc/adding.rst | 67 ---------------------- 1 file changed, 67 deletions(-) delete mode 100644 examples/qml/referenceexamples/adding/doc/adding.rst (limited to 'examples/qml/referenceexamples/adding/doc') diff --git a/examples/qml/referenceexamples/adding/doc/adding.rst b/examples/qml/referenceexamples/adding/doc/adding.rst deleted file mode 100644 index d06ff0a5a..000000000 --- a/examples/qml/referenceexamples/adding/doc/adding.rst +++ /dev/null @@ -1,67 +0,0 @@ -.. _qml-adding-types-example: - -Extending QML - Adding Types Example -==================================== - -The Adding Types Example shows how to add a new object type, ``Person``, to QML. -The ``Person`` type can be used from QML like this: - -.. code-block:: javascript - - import examples.adding.people - - Person { - name: "Bob Jones" - shoe_size: 12 - } - -Declare the Person Class ------------------------- - -All QML types map to C++ types. Here we declare a basic C++ Person class -with the two properties we want accessible on the QML type - name and shoeSize. -Although in this example we use the same name for the C++ class as the QML -type, the C++ class can be named differently, or appear in a namespace. - -The Person class implementation is quite basic. The property accessors simply -return members of the object instance. - -.. code-block:: python - - from PySide6.QtCore import QObject, Property - from PySide6.QtQml import QmlElement - - # To be used on the @QmlElement decorator - # (QML_IMPORT_MINOR_VERSION is optional) - QML_IMPORT_NAME = "People" - QML_IMPORT_MAJOR_VERSION = 1 - - - @QmlElement - class Person(QObject): - def __init__(self, parent=None): - super().__init__(parent) - self._name = '' - self._shoe_size = 0 - - @Property(str) - def name(self): - return self._name - - @name.setter - def name(self, n): - self._name = n - - @Property(int) - def shoe_size(self): - return self._shoe_size - - @shoe_size.setter - def shoe_size(self, s): - self._shoe_size = s - -Running the Example -------------------- - -The main.py file in the example includes a simple shell application that -loads and runs the QML snippet shown at the beginning of this page. -- cgit v1.2.3