diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-10-21 01:53:51 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-10-21 01:53:51 (GMT) |
commit | 10552333c84292473756900b4fdb0c4f91f12a91 (patch) | |
tree | b6d61d7d0ebd3f98d0bcc63e935daa594e12695d /doc/src | |
parent | be94259250bc84705d71a66f7c114472097c9b4d (diff) | |
parent | ee086ea4fd9baa3df94909dd9f5884578c1eaeb7 (diff) | |
download | Qt-10552333c84292473756900b4fdb0c4f91f12a91.zip Qt-10552333c84292473756900b4fdb0c4f91f12a91.tar.gz Qt-10552333c84292473756900b4fdb0c4f91f12a91.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/declarative/qmlmodels.qdoc | 45 | ||||
-rw-r--r-- | doc/src/snippets/declarative/listview/highlight.qml | 12 |
2 files changed, 51 insertions, 6 deletions
diff --git a/doc/src/declarative/qmlmodels.qdoc b/doc/src/declarative/qmlmodels.qdoc index 6ebb734..45df29b 100644 --- a/doc/src/declarative/qmlmodels.qdoc +++ b/doc/src/declarative/qmlmodels.qdoc @@ -50,12 +50,18 @@ creates an instance for each item in the model. Models may be static, or have items modified, inserted, removed or moved dynamically. Data is provided to the delegate via named data roles which the -delegate may bind to. A special \e index role containing the -index of the item in the model is also available. Models that do -not have named roles will have the data provided via the \e modelData -role. The \e modelData role is also provided for Models that have -only one role. In this case the \e modelData role contains the same -data as the named role. +delegate may bind to. The roles are exposed as properties of the +\model property, though this property is set as a default property +of the delegate so, unless there is a naming clash with a +property in the delegate, the roles are usually accessed unqualified. + +A special \e index role containing the index of the item in the model +is also available. + +Models that do not have named roles will have the data provided via +the \e modelData role. The \e modelData role is also provided for +Models that have only one role. In this case the \e modelData role +contains the same data as the named role. There are a number of QML elements that operate using data models: @@ -189,4 +195,31 @@ ListView { An Object Instance specifies a model with a single Object element. The properties of the object are provided as roles. +The example below creates a list with one item, showing the color of the +\e myText text. Note the use of the \e model property to specify the model +data rather than the \e color property of the Text element in the delegate. + +\code +Rectangle { + Text { + id: myText + text: "Hello" + color: "#dd44ee" + } + + Component { + id: myDelegate + Text { + text: model.color + } + } + ListView { + anchors.fill: parent + anchors.topMargin: 30 + model: myText + delegate: myDelegate + } +} +\endcode + */ diff --git a/doc/src/snippets/declarative/listview/highlight.qml b/doc/src/snippets/declarative/listview/highlight.qml index 2234ee7..7970ede 100644 --- a/doc/src/snippets/declarative/listview/highlight.qml +++ b/doc/src/snippets/declarative/listview/highlight.qml @@ -20,6 +20,18 @@ Rectangle { Text { text: '<b>Name:</b> ' + name } Text { text: '<b>Number:</b> ' + number } } + // Use the ListView.isCurrentItem attached property to + // indent the item if it is the current item. + states: [ + State { + name: "Current" + when: wrapper.ListView.isCurrentItem + PropertyChanges { target: wrapper; x: 10 } + } + ] + transitions: [ + Transition { NumberAnimation { properties: "x"; duration: 200 } } + ] } } //! [0] |