[solved] ListView: Change background image of selected item
-
Hi people!
I have a listview where I put a background image for each item, but I can not do to change that image when the item is clicked / touched.
Anyone have a how to explain to me how?
code:
@ ListView {
id:listviewprin
anchors.fill: telaprin
clip: true
model: animalsModel
delegate: listDelegate
focus: true
Component {
id: listDelegate
Item {
width: 480; height: 80//background image
Image {
id: imagem_fundo_listview
width: telaprin.width
height: 80
source: "qrc:/imagens/imagens/list_item.png"
Image {
id: thumbail
width: telaprin.width / 4
height: 80
source: pic
}
Text {
id: dados
text: " "+name
font.bold: false
font.pointSize: 20
anchors.left: thumbail.right
anchors.verticalCenter: parent.verticalCenter
}
}
MouseArea {
anchors.fill: parent
onClicked: {
selectedLinhaList = index;
console.log("clicado "+selectedLinhaList);
}
}
states: [
State {
name: "selected"
when: (listviewprin.currentIndex==selectedLinhaList)
// PropertyChanges {target: highlightBar; Image.y: listviewprin.currentItem.y }
}
]
}
} //Component
}//listview@Thank's.
-
In your MouseArea's onClicked function set
@ imagem_fundo_listview.source = "yournewimagepath" @ -
Ok. Can you explain it more clearly as to what is exactly happening ?