[Qt-qml] Flickable with dynamically growing children

Bo Elmgreen bo.elmgreen at gmail.com
Wed Mar 23 17:48:23 CET 2011


Hi!

Thanks for your answers. Unfortunately, I cannot share the source code, but
I had to add the ListView.anAdd signal handler in the view delegate in order
for it to work. I had added the calls to notify about the adding and removal
of rows in my data model, e.g.:

void ContactModel::addContact(Contact *contact)
 {
     qDebug() << THIS_FILE << "addContact - rowcount:" << rowCount();
     beginInsertRows(QModelIndex(), rowCount(), rowCount()+1);
     m_contacts << contact;
     endInsertRows();
 }

but that was apparently not enough. I have a feeling that it is due to that
I have set interactive to false on the list views, but I haven't tried to
verify this - so it is just a wild guess :-)

Cheers,
Bo


On Mon, Mar 21, 2011 at 7:48 AM, <martin.jones at nokia.com> wrote:

>  This should all just work automatically.  As you add items to the model
> and/or change the height of delegates, the contentHeight of the ListViewwill 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/20110323/60a359f8/attachment.html 


More information about the Qt-qml mailing list