summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets/declarative/gridview
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2009-05-06 01:03:05 (GMT)
committerMartin Jones <martin.jones@nokia.com>2009-05-06 01:03:05 (GMT)
commitdbd435148067b0b6559d34a00567f6ea98bbcaf8 (patch)
tree928a24fd88bc780f6477e40efc18a1e3160f43f4 /doc/src/snippets/declarative/gridview
parentf6e9e3ccfd5cedcdba5a0d4b606e1c794b3ea640 (diff)
downloadQt-dbd435148067b0b6559d34a00567f6ea98bbcaf8.zip
Qt-dbd435148067b0b6559d34a00567f6ea98bbcaf8.tar.gz
Qt-dbd435148067b0b6559d34a00567f6ea98bbcaf8.tar.bz2
GridView docs.
Diffstat (limited to 'doc/src/snippets/declarative/gridview')
-rw-r--r--doc/src/snippets/declarative/gridview/dummydata/ContactModel.qml23
-rw-r--r--doc/src/snippets/declarative/gridview/gridview.qml45
-rw-r--r--doc/src/snippets/declarative/gridview/pics/portrait.pngbin0 -> 3126 bytes
3 files changed, 68 insertions, 0 deletions
diff --git a/doc/src/snippets/declarative/gridview/dummydata/ContactModel.qml b/doc/src/snippets/declarative/gridview/dummydata/ContactModel.qml
new file mode 100644
index 0000000..accbc3e
--- /dev/null
+++ b/doc/src/snippets/declarative/gridview/dummydata/ContactModel.qml
@@ -0,0 +1,23 @@
+ListModel {
+ id: ContactModel
+ ListElement {
+ name: "Bill Smith"
+ number: "555 3264"
+ portrait: "pics/portrait.png"
+ }
+ ListElement {
+ name: "Jim Williams"
+ number: "555 5673"
+ portrait: "pics/portrait.png"
+ }
+ ListElement {
+ name: "John Brown"
+ number: "555 8426"
+ portrait: "pics/portrait.png"
+ }
+ ListElement {
+ name: "Sam Wise"
+ number: "555 0473"
+ portrait: "pics/portrait.png"
+ }
+}
diff --git a/doc/src/snippets/declarative/gridview/gridview.qml b/doc/src/snippets/declarative/gridview/gridview.qml
new file mode 100644
index 0000000..0fca789
--- /dev/null
+++ b/doc/src/snippets/declarative/gridview/gridview.qml
@@ -0,0 +1,45 @@
+//! [3]
+Rect {
+ width: 240; height: 180; color: "white"
+ // ContactModel model is defined in dummydata/ContactModel.qml
+ // The viewer automatically loads files in dummydata/* to assist
+ // development without a real data source.
+
+ // Define a delegate component. A component will be
+ // instantiated for each visible item in the list.
+//! [0]
+ Component {
+ id: Delegate
+ Item {
+ id: Wrapper
+ width: 80; height: 78
+ VerticalLayout {
+ Image { source: portrait; anchors.horizontalCenter: parent.horizontalCenter }
+ Text { text: name; anchors.horizontalCenter: parent.horizontalCenter }
+ }
+ }
+ }
+//! [0]
+ // Define a highlight component. Just one of these will be instantiated
+ // by each ListView and placed behind the current item.
+//! [1]
+ Component {
+ id: Highlight
+ Rect {
+ color: "lightsteelblue"
+ radius: 5
+ }
+ }
+//! [1]
+ // The actual grid
+//! [2]
+ GridView {
+ width: parent.width; height: parent.height
+ model: ContactModel; delegate: Delegate
+ cellWidth: 80; cellHeight: 80
+ highlight: Highlight
+ focus: true
+ }
+//! [2]
+}
+//! [3]
diff --git a/doc/src/snippets/declarative/gridview/pics/portrait.png b/doc/src/snippets/declarative/gridview/pics/portrait.png
new file mode 100644
index 0000000..fb5052a
--- /dev/null
+++ b/doc/src/snippets/declarative/gridview/pics/portrait.png
Binary files differ