[Qt-qml] Tab widget example confusion

David Boddie david.boddie at nokia.com
Mon Jul 5 14:41:03 CEST 2010


Last week, some of us were looking at some of the examples in the declarative
directory and were initially confused about the ui-components/tabwidget
example.

We realized that there are two things you need to know to be able to
understand what the example is doing:

 1. The default property of an element is the property that holds
    the elements defined within it; i.e., the child elements.
 2. For Item-based elements, the children property is the default
    property, but this example replaces the default property of the
    TabWidget, making it an alias for the children property of a child
    element.

This makes it possible to define the tabs within the TabWidget element when
it is used, but makes it hard to see why it works that way. Just one line in
the TabWidget makes a huge difference to the working of the example:

    default property alias content: stack.children

After some experimentation, we came up with an alternative way to implement
the example that used a property containing a list of elements defining the
contents of each tab. This seemed to make the working of the example a bit
more obvious, but we still had to alias an existing children property
because we didn't know how to create a new property that could hold a list
of elements.

Should we be writing more examples like this that do things with the default
interpretation of elements, or was this the only realistic way to achieve the
desired behavior for this example?

David
-- 
David Boddie
Senior Technical Writer
Nokia, Qt



More information about the Qt-qml mailing list