summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-06-08 01:36:49 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-06-08 01:36:49 (GMT)
commit31de141d722a2994b98f079b5be91a98cb34a3dc (patch)
treeb9adf3e476db3c898d0efbe7ed9fc06d0549a2f5 /examples
parent315d186907c60b894b0bb1cf21e11758ee52966a (diff)
downloadQt-31de141d722a2994b98f079b5be91a98cb34a3dc.zip
Qt-31de141d722a2994b98f079b5be91a98cb34a3dc.tar.gz
Qt-31de141d722a2994b98f079b5be91a98cb34a3dc.tar.bz2
Add an example of animated item add/remove in ListView
Diffstat (limited to 'examples')
-rw-r--r--examples/declarative/modelviews/listview/dynamic.qml33
1 files changed, 33 insertions, 0 deletions
diff --git a/examples/declarative/modelviews/listview/dynamic.qml b/examples/declarative/modelviews/listview/dynamic.qml
index cf0e387..df2e094 100644
--- a/examples/declarative/modelviews/listview/dynamic.qml
+++ b/examples/declarative/modelviews/listview/dynamic.qml
@@ -95,6 +95,7 @@ Rectangle {
id: fruitDelegate
Item {
+ id: wrapper
width: container.width; height: 55
Column {
@@ -169,6 +170,38 @@ Rectangle {
MouseArea { anchors.fill:parent; onClicked: fruitModel.remove(index) }
}
+
+ // Animate adding and removing items
+ ListView.delayRemove: true // so that the item is not destroyed immediately
+ ListView.onAdd: state = "add"
+ ListView.onRemove: state = "remove"
+ states: [
+ State {
+ name: "add"
+ PropertyChanges { target: wrapper; height: 55; clip: true }
+ },
+ State {
+ name: "remove"
+ PropertyChanges { target: wrapper; height: 0; clip: true }
+ }
+ ]
+ transitions: [
+ Transition {
+ to: "add"
+ SequentialAnimation {
+ NumberAnimation { properties: "height"; from: 0; to: 55 }
+ PropertyAction { target: wrapper; property: "state"; value: "" }
+ }
+ },
+ Transition {
+ to: "remove"
+ SequentialAnimation {
+ NumberAnimation { properties: "height" }
+ // Make sure delayRemove is set back to false so that the item can be destroyed
+ PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: false }
+ }
+ }
+ ]
}
}