[Qt-qml] Flickable with dynamically growing children

martin.jones at nokia.com martin.jones at nokia.com
Mon Mar 21 07:48:49 CET 2011


This should all just work automatically.  As you add items to the model and/or change the height of delegates, the contentHeight of the ListView will be updated accordingly.

You can only use ListView.onAdd in a delegate.

It would be helpful to see a working example.

Br,
Martin.

From: qt-qml-bounces+martin.jones=nokia.com at qt.nokia.com [mailto:qt-qml-bounces+martin.jones=nokia.com at qt.nokia.com] On Behalf Of ext Bo Elmgreen
Sent: Friday, 18 March 2011 8:29 PM
To: qt-qml at qt.nokia.com
Subject: [Qt-qml] Flickable with dynamically growing children

Hi all,

I have been playing around with the following example:
http://wiki.forum.nokia.com/index.php/How_to_create_a_Collapsible_Panel_with_QML

I would like to have a list with two collapsible groups, but instead of each group being flickable, as in the example, I would like the combined list to be flickable.
So, I have embedded my two collapsible panels in a Flickable item and set their interactive properties to false. This works ok as long as I have a static elements in the two lists or if they are loaded from a file. But now I receive the elements over a network connection one by one, and then I have problems with setting the height - both of the two lists and of the content of the surrounding flickable :-/ Now I give the Flickable's contentHeight a default value as well as the two collapsible panels, and then I try to update their height dynamically by reacting on ListView.onAdd in their ListViews:

ListView{

        id: listView

        width: parent.width

        height: parent.height-titleRect.height

        anchors.top: titleRect.bottom

        interactive: false

        model: customModel

        delegate: customDelegate

        ListView.onAdd: { myRect.setHeight(60); console.log("listview on add") }

    }

- but it doesn't seem to be called... so their heights remain fixed.

So, I was wondering if there was a "standard way" of handling this?

Thanks,
Bo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt.nokia.com/pipermail/qt-qml/attachments/20110321/6564064f/attachment-0001.html 


More information about the Qt-qml mailing list