From 5f9091771eaa26db5ad35e4788c13ac011512b61 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Tue, 27 Oct 2009 20:03:35 +1000 Subject: Doc --- doc/src/declarative/pics/repeater-index.png | Bin 0 -> 3024 bytes doc/src/snippets/declarative/repeater-index.qml | 15 +++++++++++++++ src/declarative/fx/qfxrepeater.cpp | 12 ++++++++++-- 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 doc/src/declarative/pics/repeater-index.png create mode 100644 doc/src/snippets/declarative/repeater-index.qml diff --git a/doc/src/declarative/pics/repeater-index.png b/doc/src/declarative/pics/repeater-index.png new file mode 100644 index 0000000..3dbe6d0 Binary files /dev/null and b/doc/src/declarative/pics/repeater-index.png differ diff --git a/doc/src/snippets/declarative/repeater-index.qml b/doc/src/snippets/declarative/repeater-index.qml new file mode 100644 index 0000000..9063967 --- /dev/null +++ b/doc/src/snippets/declarative/repeater-index.qml @@ -0,0 +1,15 @@ +import Qt 4.6 + +Rectangle { + width: 50; height: childrenRect.height; color: "white" + +//! [0] + Column { + Repeater { + model: 10 + Text { text: "I'm item " + index } + } + } +//! [0] +} + diff --git a/src/declarative/fx/qfxrepeater.cpp b/src/declarative/fx/qfxrepeater.cpp index 182dcc7..94954e7 100644 --- a/src/declarative/fx/qfxrepeater.cpp +++ b/src/declarative/fx/qfxrepeater.cpp @@ -72,10 +72,18 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Repeater,QFxRepeater) The model may be either an object list, a string list, a number or a Qt model. In each case, the data element and the index is exposed to each instantiated - component. The index is always exposed as an accessible \c index property. + component. + + The index is always exposed as an accessible \c index property. In the case of an object or string list, the data element (of type string or object) is available as the \c modelData property. In the case of a Qt model, - all roles are available as named properties just like in the view classes. + all roles are available as named properties just like in the view classes. The + following example shows how to use the index property inside the instantiated + items. + + \snippet doc/src/snippets/declarative/repeater-index.qml 0 + + \image repeater-index.png Items instantiated by the Repeater are inserted, in order, as children of the Repeater's parent. The insertion starts immediately after -- cgit v0.12