[Qt-qml] How to access item in ListView delegate?

Shawn shawn at forevertrusts.com
Thu Sep 8 12:18:24 CEST 2011


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



More information about the Qt-qml mailing list