[Qt-qml] How to update item within a Row

Girish Ramakrishnan girish at forwardbias.in
Mon Jan 3 07:07:21 CET 2011


Hi,

On Sun, Jan 2, 2011 at 11:20 PM,  <mathias.malmqvist at nokia.com> wrote:
> Although I appreciate any votes I can get on my defects reports ;) that is the
> wrong way to solve your problem.
>

It is probably the wrong way to address the problem for which you had
created the requested. Maybe I should create an alternate bug report?
I don't see any downside in providing an API to access Repeater's
elements.

> The right way is to create a ListModel containing ListElements holding the properties
> that you bind to the items in the Row. Then to change an item in the row just change
> the property of that ListElement.
>

While I don't disagree with above, I do think a Repeater should
provide a function to access elements it created. In my case, I had to
transfer the focus from one button to another in a ButtonGroup.qml. To
find the next child, I have to iterate over the repeater's parent's
children in javascript (skipping the 'repeater'). I didn't like that,
so I ended up with an alternate hack - to bind the item's focus
property with a hasFocus property in the model. But that approach
won't work if you have to call some methods in the item like
forceActiveFocus() or you need to call a method in some custom C++
QDeclarativeItem etc.

Girish


More information about the Qt-qml mailing list