Ah, so you are trying the "single view/multiple models" approach again.
But if you want to change and icon depending on a value of the current data item, then you don't need to do any imperative coding at all.
Let say you have an image
Image {
source: model.horizontal ? "horizontal.png" : "vertical.png"
}
Image {
source: model.horizontal ? "horizontal.png" : "vertical.png"
}
To copy to clipboard, switch view to plain text mode
Or with animated transitions
Image {
id: icon
state: model.horizontal ? "Horizontal" : "Vertical"
states: [
State {
name: "Horizontal"
PropertyChanges {
target: icon
source: "horizontal.png"
}
},
State {
name: "Vertical"
PropertyChanges {
target: icon
source: "vertical.png"
}
}
]
transitions: [
Transition {
from: "Horizontal"; to: "Vertical"
// Animations here
},
Transition {
from: "Vertical"; to: "Horizontal"
// Animations here
}
]
}
Image {
id: icon
state: model.horizontal ? "Horizontal" : "Vertical"
states: [
State {
name: "Horizontal"
PropertyChanges {
target: icon
source: "horizontal.png"
}
},
State {
name: "Vertical"
PropertyChanges {
target: icon
source: "vertical.png"
}
}
]
transitions: [
Transition {
from: "Horizontal"; to: "Vertical"
// Animations here
},
Transition {
from: "Vertical"; to: "Horizontal"
// Animations here
}
]
}
To copy to clipboard, switch view to plain text mode
Cheers,
_
Bookmarks