[Qt-qml] Element at 'index' in Column or Row

mathias.malmqvist at nokia.com mathias.malmqvist at nokia.com
Thu May 6 18:04:33 CEST 2010


> I'm fairly sure testcolumn.children[5].text = "foo" should do it.

It would probably work in this case, but it's very bad style to use the children 
property, for anything really. This is because QML may add whatever children
it feels like, so there's no guarantee that the repeater's first delegate instance
is forever its child at index 0.

Rakesh, the proper way of doing what you want is to define a ListModel for 
your repeater and give its ListElements a property that you bind to the Text
element's text property. Then to change the text of a particular repeater delegate
just change the corresponding ListElement's property.

See
http://doc.qt.nokia.com/4.7-snapshot/qml-listmodel.html#setProperty-method
(and http://bugreports.qt.nokia.com/browse/QTBUG-10458)


Cheers
Mathias

------------------------------------------------------------
Mathias Malmqvist
CWRT Prototype Lead
S SE UX Prototyping GB
10 Great Pulteney Street, London, W1F 9NB, UK
Got no reply? Try giving me a call:
Mobile: +44 (0)77 6522 2738
http://www.nokia.com

________________________________________
From: qt-qml-bounces at trolltech.com [qt-qml-bounces at trolltech.com] On Behalf Of Kamm Christian.D (Nokia-D/Berlin)
Sent: Wednesday, April 28, 2010 8:21 AM
To: qt-qml at trolltech.com
Subject: Re: [Qt-qml] Element at 'index' in Column or Row

On Wednesday 28 April 2010 09:03:02 ext Rakesh.Mutharaju at tieto.com wrote:
>         How can I access Element at particular 'index' in Column or Row.
>  Basically I would like to update the content of element at runtime.
>
> For eg.,
>
> Column {
> id: testcolumn
> spacing: 2
> height: 150
> width:100
>         Repeater{
>                 model: 10
>                 Text{
>                         id: textelement
>                         height: 10
>                         text: "test"+index
>                    }
>         }
> }
>
> I would like to update the Text element at index '5' , how can access the
>  Text element??

I'm fairly sure testcolumn.children[5].text = "foo" should do it.

Regards,
Christian
_______________________________________________
Qt-qml mailing list
Qt-qml at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-qml




More information about the Qt-qml mailing list