aboutsummaryrefslogtreecommitdiffstats
path: root/examples/declarative/referenceexamples/default/doc/default.rst
blob: 1b28519a7cac55bda8a42eb67beec69e9a237b10 (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
.. _qml-default-property-example:

Extending QML - Default Property Example
========================================

This example builds on the :ref:`qml-adding-types-example`,
the :ref:`qml-object-and-list-property-types-example` and
the :ref:`qml-inheritance-and-coercion-example`.

The Default Property Example is a minor modification of the
:ref:`qml-inheritance-and-coercion-example` that simplifies the
specification of a BirthdayParty through the use of a default property.

Declaring the BirthdayParty Class
---------------------------------

The only difference between this example and the last, is the addition of a
``DefaultProperty`` class info annotation.

The default property specifies the property to assign to whenever an explicit
property is not specified, in the case of the BirthdayParty type the guest
property.  It is purely a syntactic simplification, the behavior is identical
to specifying the property by name, but it can add a more natural feel in many
situations.  The default property must be either an object or list property.

Running the Example
-------------------

The main.py file in the example includes a simple shell application that
loads and runs the QML snippet shown below.