[Qt-qml] ListView's childrenRect

jerome.pasion at nokia.com jerome.pasion at nokia.com
Tue Nov 16 23:13:02 CET 2010


Hello all,

Someone sent me his problem with ListView's childrenRect. Essentially, binding the ListView's height to the childrenRect.height when using a regular ListModel (with strings) will only show the first element while using the XmlListModel will fit all the model's items.

Here is his code snippet:
    ListView {
        id: list

        interactive: false
        //height: contentHeight //If bound to contentHeight warning is given that there is a binding loop!
        height: childrenRect.height //If bound to childrenRect.height then only one item is shown (unless you use an XMLListModel!)
        //contentHeight: childrenRect.height //Not really necessary
        width: parent.width
        model: listModel
        //model: xmlListModel //If the XMLListModel is used, then the childrenrect binding is fine
        delegate: listItem
    }
}

What would be the best way of fitting the contents of any/all types of models?

Cheers,
Jerome P.




More information about the Qt-qml mailing list