Using Timer in a ListView
-
Hello,
I 'm trying to create a ListView with following behavior: If I click an Item it will vertically expand but after some time it will collapse back to it's original size. I suppose I need to create a timer which will change the state of the expanded delegate back to default.
Unfortunately the documentation for Timer didn't help me much.
-
I hope this helps:
@import QtQuick 1.0
Rectangle {
property int time: 800
property int size: 300
width: size; height: size; radius: size
color: "red"
Behavior on radius { NumberAnimation { duration: time } }
Timer {
id: reset
interval: time;
onTriggered: parent.radius = size
}MouseArea { anchors.fill: parent onClicked: { parent.radius = 0; reset.start() } }
}@
Just hacked it up. It starts with a circle. Click it and it turns in to a rectangle and after becoming a rectangle, it will turn in to a circle again (with a Timer).
-
[quote author="xsacha" date="1291284121"]I hope this helps:
@import QtQuick 1.0
Rectangle {
property int time: 800
property int size: 300
width: size; height: size; radius: size
color: "red"
Behavior on radius { NumberAnimation { duration: time } }
Timer {
id: reset
interval: time;
onTriggered: parent.radius = size
}MouseArea { anchors.fill: parent onClicked: { parent.radius = 0; reset.start() } }
}@
Just hacked it up. It starts with a circle. Click it and it turns in to a rectangle and after becoming a rectangle, it will turn in to a circle again (with a Timer).[/quote]
Thanks for the sample eg.