summaryrefslogtreecommitdiffstats
path: root/doc/src
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2009-10-21 01:40:50 (GMT)
committerMartin Jones <martin.jones@nokia.com>2009-10-21 01:40:50 (GMT)
commitdb6a53356aa72e59fcbc631c5cde77c14d51acc1 (patch)
tree4c5ad2bbbf20fde53226d7c3a2cc8ad608f19853 /doc/src
parent23855460a40a5a866837ca9b4348abc257a90ad1 (diff)
downloadQt-db6a53356aa72e59fcbc631c5cde77c14d51acc1.zip
Qt-db6a53356aa72e59fcbc631c5cde77c14d51acc1.tar.gz
Qt-db6a53356aa72e59fcbc631c5cde77c14d51acc1.tar.bz2
Docs.
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/declarative/qmlmodels.qdoc45
-rw-r--r--doc/src/snippets/declarative/listview/highlight.qml12
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]