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.1
Rectangle {
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;
}
}
}
import QtQuick 2.0
import QtQuick.Window 2.1
Rectangle {
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;
}
}
}
To copy to clipboard, switch view to plain text mode
Added after 21 minutes:
Hi,
I removed the PropertyAction line and replaced with ScriptAction {script: listView.model = model2;}
That seems to work.
Bookmarks