10-08-2013 07:14 PM
expandableMessage.headerTextVisible.visible = true;
expandableMessage.bodyTextVisible.visible = false;
in ListItem.onDataChanged and adding to expandablelabel
property alias headerTextVisible: lblTitle.visible
property alias bodyTextVisible: lblBody.visible
doesn't fix it, I'm at a loss. I am not getting any qml errors in the console when ondatachnaged is called.
10-08-2013 07:29 PM - edited 10-08-2013 07:39 PM
Could you verify that onDataChanged is getting called at all? (by adding a console.log() statement to it)
It will work only when defined at top level item of ListItemComponent.
By the way, directly modifying ListItemComponent properties such as
lblBody.visible = true;
won't work because ListView reuses these ListItemComponents as it sees fit. It will rearrange them during scrolling and their state will be lost.
How many items do you need to display? Sometimes it's easier to simply add them to a Container without using ListView at all.
When using ListView, it's better to create a model with all the needed flags (isExpanded etc) and map visual components state to model properties. When state has to be changed, modify the model accordingly. ListView will display the new state. This has some limitations though. I had problems with updating DropDown component using this approach.
UPD: thread with some sample code. Works for 'title' property, but I was unable to update DropDown's values:
I don't know if it will work when binding to 'visible' property.
10-08-2013 07:37 PM
onDataChanged is definatly being called.
lblBody.visible is being set through an alias I added to explanablelabel when ondatachanged is called - is that wrong?
The ListView is populated dynamically and needs to load more and more items when it reaches the end of the data.
10-08-2013 07:47 PM
10-08-2013 07:51 PM
Ok thanks, I'm starting to realise this - I just thought something as simple as editing the text or visibility wouldnt require an update to the actual object in the model, that thought cost me hours of wasted time!