Hi Riaan, Thank you for your suggestion, I add index attribute to the model, then it will work. If model is from C++, I think the theory should be the same. Rectangle { width: 180; height: 200 ListModel { id: model ListElement { name: "Bill Smith" number: "555 3264" index: 0 } ListElement { name: "John Brown" number: "555 8426" index: 1 } ListElement { name: "Sam Wise" number: "555 0473" index: 2 } }
Component { id: contactDelegate Item { width: 180; height: 40 scale: (view.currentIndex == index) ? 1.2 : 1 Column { Text { text: '<b>Name:</b> ' + name } Text { text: '<b>Number:</b> ' + number } } } } ListView { id: view anchors.fill: parent model: model delegate: contactDelegate highlight: Rectangle { color: "lightsteelblue"; radius: 5 } focus: true } } Best Regards, Shawn On Thu, 2011-09-08 at 12:37 +0200, Riaan Kruger wrote: > Are you trying to scale the current item in testView? > If so you should probably do it in the delegate with something like: > Image { > id: image > width: 30 > height: 30 > source: model.contactImage > scale: parent.index == testview.currentIndex ? 2 :1 > } > > PS:Have not tested the above > > > On Thu, Sep 8, 2011 at 12:18 PM, Shawn <sh...@forevertrusts.com> 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@qt.nokia.com > > http://lists.qt.nokia.com/mailman/listinfo/qt-qml > > _______________________________________________ Qt-qml mailing list Qt-qml@qt.nokia.com http://lists.qt.nokia.com/mailman/listinfo/qt-qml