aboutsummaryrefslogtreecommitdiffstats
path: root/examples/qml/referenceexamples/coercion/doc/coercion.rst
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2022-09-15 13:21:53 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2022-09-16 10:30:36 +0200
commitcf32b66adbfb489cd6e5d5c0bf3f741b59ba204c (patch)
tree44be69c9487f5d4db1092d061a555bd6001c1ab4 /examples/qml/referenceexamples/coercion/doc/coercion.rst
parentb20d6f6906f91f9df608d7800f4e27f7a7160abe (diff)
Move examples around
Change the directory structure to closer match that of Qt. Task-number: PYSIDE-841 Change-Id: I87aca346b6654aafe94dd1fb83c184c182ceb2e6 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'examples/qml/referenceexamples/coercion/doc/coercion.rst')
-rw-r--r--examples/qml/referenceexamples/coercion/doc/coercion.rst35
1 files changed, 35 insertions, 0 deletions
diff --git a/examples/qml/referenceexamples/coercion/doc/coercion.rst b/examples/qml/referenceexamples/coercion/doc/coercion.rst
new file mode 100644
index 000000000..2ccdaeb4f
--- /dev/null
+++ b/examples/qml/referenceexamples/coercion/doc/coercion.rst
@@ -0,0 +1,35 @@
+.. _qml-inheritance-and-coercion-example:
+
+Extending QML - Inheritance and Coercion Example
+================================================
+
+This example builds on the :ref:`qml-adding-types-example` and the
+:ref:`qml-object-and-list-property-types-example` .
+
+The Inheritance and Coercion Example shows how to use base classes to assign
+types of more than one type to a property. It specializes the Person type
+developed in the previous examples into two types - a ``Boy`` and a ``Girl``.
+
+Declare Boy and Girl
+--------------------
+
+The Person class remains unaltered in this example and the Boy and Girl C++
+classes are trivial extensions of it. The types and their QML name are
+registered with the QML engine.
+
+As an example, the inheritance used here is a little contrived, but in real
+applications it is likely that the two extensions would add additional
+properties or modify the Person classes behavior.
+
+Running the Example
+-------------------
+
+The BirthdayParty type has not changed since the previous example. The
+celebrant and guests property still use the People type.
+
+However, as all three types, Person, Boy and Girl, have been registered with the
+QML system, on assignment QML automatically (and type-safely) converts the Boy
+and Girl objects into a Person.
+
+The main.py file in the example includes a simple shell application that
+loads and runs the QML snippet shown below.