[Qt-qml] how to expose nested ListModel from C++ to QML?

bea.lam at nokia.com bea.lam at nokia.com
Fri Dec 10 06:09:01 CET 2010


Hi James,

On 10/12/2010, at 2:20 PM, ext Wei, Xiaohai wrote:

> Thanks. 
> 
> another question on nested listview. 
> 
> How can inner delegate get the index of current outer model index?
> 

One way to do it is to add a property to each delegate of the outer view, which holds the 'index' value of that the delegate. The index can then be accessed by the inner view. E.g.

Component {
    id: outerDelegate

    Repeater {
        id: outerDelegate
        property int outerIndex: index

        model: ...
        delegate: Text { text: outerDelegate.outerIndex }

    }
}

regards,

Bea



More information about the Qt-qml mailing list