diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-05-06 04:43:08 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-05-06 04:43:08 (GMT) |
commit | 2378ac0622ae48a382ae3189ac9ca7d74174d982 (patch) | |
tree | 41636cc501dab257b7fabaee5f9431196b4fcd97 /src/declarative/util/qmllistmodel.cpp | |
parent | 8f23ea2dc59afaf74a7699aa9334dc7ec61e9d4f (diff) | |
download | Qt-2378ac0622ae48a382ae3189ac9ca7d74174d982.zip Qt-2378ac0622ae48a382ae3189ac9ca7d74174d982.tar.gz Qt-2378ac0622ae48a382ae3189ac9ca7d74174d982.tar.bz2 |
doc
Diffstat (limited to 'src/declarative/util/qmllistmodel.cpp')
-rw-r--r-- | src/declarative/util/qmllistmodel.cpp | 59 |
1 files changed, 36 insertions, 23 deletions
diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp index 6ad0cb9..1cd2f69 100644 --- a/src/declarative/util/qmllistmodel.cpp +++ b/src/declarative/util/qmllistmodel.cpp @@ -72,24 +72,25 @@ Q_DECLARE_METATYPE(QListModelInterface *); \qmlclass ListModel \brief The ListModel element defines a free-form list data source. - The ListModel is a simple XML heirarchy of items containing data roles. + The ListModel is a simple heirarchy of items containing data roles. For example: \code - <ListModel id="FruitModel"> - <Fruit> - <name>Apple</name> - <cost>2.45</cost> - <Fruit> - <Fruit> - <name>Orange</name> - <cost>3.25</cost> - </Fruit> - <Fruit> - <name>Banana</name> - <cost>1.95</cost> - </Fruit> - </ListModel> + ListModel { + id: FruitModel + ListElement { + name: "Apple" + cost: 2.45 + } + ListElement { + name: "Orange" + cost: 3.25 + } + ListElement { + name: "Banana" + cost: 1.95 + } + } \endcode Elements beginning with a capital are items. Elements beginning @@ -98,14 +99,26 @@ Q_DECLARE_METATYPE(QListModelInterface *); The defined model can be used in views such as ListView: \code - <Component id="FruitDelegate"> - <Item width="200" height="50"> - <Text text="{name}"/> - <Text text="{'$'+cost}" anchors.right="{parent.right}"/> - </Item> - </Component> - - <ListView model="{FruitModel}" delegate="{FruitDelegate}" anchors.fill="{parent}"/> + Component { + id: FruitDelegate + Item { + width: 200 + height: 50 + Text { + text: name + } + Text { + text: '$'+cost + anchors.right: parent.right + } + } + } + + ListView { + model: FruitModel + delegate: FruitDelegate + anchors.fill: parent + } \endcode */ |