[SOLVED] Changing model property of ListView during animation
-
Hi,
I am using the PropertyAction method to change the value of my "model" property for a ListView that I am animating. Does not work. Any idea why?
-
Could you please provide us your code so we can check where the problem could be?
-
yep, sorry .. I just thought maybe not being able to change models during an animation might be normal behavior. I'll isolate the issue and post it here when I get in.
thnx
-
Im not sure if it has to work or it hasn't to work, but okay, isolate the problem and post us your result when you've got it.
-
Hi,
Okay, here is a simple example of the behavior. When I set the "model" property of the listView between the two NumberAnimations I am hoping the list contents will change to those from model2. However, when I hit the "up arrow" key there are no errors thrown and the list is not visible.
I feel like I am using PropertyAction incorrectly, but I don't know what I am doing wrong. I tried putting model2 in quotes but that did not work either.
Thanks
@
import QtQuick 2.0
import QtQuick.Window 2.1Rectangle {
id: mainView
width: Screen.desktopAvailableWidth
height: Screen.desktopAvailableHeight
color: "black"ListModel { id: model1 ListElement { name: "Apple" } ListElement { name: "Orange" } ListElement { name: "Banana" } } ListModel { id: model2 ListElement { name: "Avacado" } ListElement { name: "Tomato" } ListElement { name: "Onion" } } Component { id: listDelegate Column { Text { color: "white"; text: name; font.pointSize: 36 } } } ListView { id: listView spacing: 50 anchors.fill: parent model: model1 delegate: listDelegate width: Screen.desktopAvailableWidth - 50; height: Screen.desktopAvailableHeight; SequentialAnimation { id: seqAnim NumberAnimation { target: listView; property: "opacity"; to: 0; duration: 1000 } PropertyAction { target: listView; properties: "model"; value: model2 } NumberAnimation { target: listView; property: "opacity"; to: 1; duration: 1000 } } focus: true Keys.onUpPressed: { seqAnim.running = true; } }
}
@
-
Hey,
im sorry but i can't help you yet because i didn't work that much with animations and transitions. However, you could do it by setting @listView.model = model2@
manually, but thats not a good solution. Maybe i'll find a solution later or tomorrow. -
Hi,
I removed PropertyAction line and used this instead ..
@ScriptAction { script: listView.model = model2; }@
That seems to work!
thnx