Welcome!

Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Cascades Development

Reply
Regular Contributor
Guillaume_LACHAUD
Posts: 60
Registered: ‎12-19-2012
My Carrier: SFR

Access view children of a ListView

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

Please use plain text.
Developer
Zmey
Posts: 914
Registered: ‎12-18-2012

Re: Access view children of a ListView

[ Edited ]

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.

Please use plain text.
Regular Contributor
Guillaume_LACHAUD
Posts: 60
Registered: ‎12-19-2012
My Carrier: SFR

Re: Access view children of a ListView

Yes but this will give me access to the data of the item, not the view itself.

Please use plain text.
Developer
Zmey
Posts: 914
Registered: ‎12-18-2012

Re: Access view children of a ListView

Access the view in ListItemProvider's updateItem().

Modify the data to trigger updates.

Please use plain text.
Contributor
developer_gslab
Posts: 10
Registered: ‎10-29-2012
My Carrier: Idea

Re: Access view children of a ListView

has anybody done this yet?
Please use plain text.
Developer
igosoft
Posts: 71
Registered: ‎09-19-2012
My Carrier: Play

Re: Access view children of a ListView

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.

 

Please use plain text.
Developer
kylefowler
Posts: 479
Registered: ‎05-17-2009
My Carrier: ATT

Re: Access view children of a ListView

Because the listitems are recycled, and the fact that they are based on the underlying data, I would suggest that you have whatever dynamic data you are wanting to add already in the item just set to visible=false.

Then you can update the underlying data and can make the content show based on whatever criteria needs to be met for that section to show. The listview and components structure was not designed to update a single cell and its data since the data changes in a single component as scrolling happens.
Like all of my posts
Please use plain text.
Contributor
developer_gslab
Posts: 10
Registered: ‎10-29-2012
My Carrier: Idea

Re: Access view children of a ListView

Actually I've to show a Label inside listView items. Certain alphabets of the Label will be colored based on some logic. How to get certain alphabets of the Label colored deserves another post. But for this thread, whenever a row is created or recycled I want to run the logic to present the Label with text colored.
Please use plain text.