12-27-2012 11:26 AM
Hi !
I have a ListView and would like to inject some elements in the container of the row, based upon very specific circumstances. Hence, I have to do this from c++. From a ListView object, I am using the children() method to get a ListItemComponent, a class only available in QML according to the Documentation. But how can I acess a child view of a ListView in C++ ?
Thanks
12-27-2012 12:42 PM - edited 12-27-2012 01:05 PM
I don't know how to access the data from C++ if ListView was created using ListItemComponents.
But you can configure ListView to use a model (one of DataModel subclasses) and ListItemProvider to create the items. Then access the data using the model:
listView.model().data(indexPath)
listView.model().childCount()
When model is updated listView will call ListItemProvider's updateItem() where you can make the changes to visuals.
Keeping a pointer to visual item to change it directly is unsafe because ListView owns it and can reuse it for other row at any moment.
12-28-2012 03:14 AM
Yes but this will give me access to the data of the item, not the view itself.
12-28-2012 03:43 AM
Access the view in ListItemProvider's updateItem().
Modify the data to trigger updates.
02-17-2013 02:12 AM
02-17-2013 01:31 PM
Please provide more details about what you want to do. An example with cpp and qml will help to understand your goals.. Many devs complicate simple things.
You can use control delegates to change ui of listview items.
02-17-2013 06:24 PM
02-18-2013 04:41 AM