[Qt-qml] How to access item in ListView delegate?
Jesus Fernandez
jsfdez at gmail.com
Thu Sep 8 12:28:43 CEST 2011
Hi,
I think the correct way is to modify the model directly so the delegate will
update if the bindings are correct.
You can define the delegate as something like this:
Component{
id:testViewDelegate
Item{
scale: model.isScaled ? 2 : 1
width: 100
height: 30
Image {
id: image
width: 30
height: 30
source: model.contactImage
}
}
Best regards.
On Thursday, September 8, 2011, Shawn wrote:
> Hi guys,
>
> I want to access item in ListView delegate, like below code snippet,
> I want to change image's property, which is in the delegate of testView.
> It doesn't work. How can I access it or am I in the wrong way?
> Any suggestion could be helpful.
> Thank you very much!
> ListView {
> id: testView
> model: easyNameModel
> delegate: testViewDelegate
> highlight: Rectangle {color: "green"; radius: 5;
> width: listview2.width; height: itemHeight
> }
>
> Keys.onPressed: {
> if(event.key == Qt.Key_Down)
> {
> //image.scale = 2; // This doesn't work
> listview2.incrementCurrentIndex();
> }
>
> }
>
> Component{
> id:testViewDelegate
> Item{
> width: 100
> height: 30
> Image {
> id: image
> width: 30
> height: 30
> source: model.contactImage
> }
> }
> }
> }
>
>
> Best Regards,
> Shawn
>
> _______________________________________________
> Qt-qml mailing list
> Qt-qml at qt.nokia.com <javascript:;>
> http://lists.qt.nokia.com/mailman/listinfo/qt-qml
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt.nokia.com/pipermail/qt-qml/attachments/20110908/22857a08/attachment.html
More information about the Qt-qml
mailing list