02-28-2013 08:15 AM
Hi, I'm hoping someone can help me with this.
I have a ListView and from my button's onClicked, I want to add checkbox to the ListItemComponents.
How can I achieve this? Can this even be done? The variable scope is really annoying.
Solved! Go to Solution.
02-28-2013 08:32 AM - edited 02-28-2013 08:34 AM
You can replace any StandardListItem with one of your own including one with a checkbox in.
Reading this page shows you how...
02-28-2013 08:49 AM - edited 02-28-2013 08:52 AM
I'm going to answer your question in a different way as well in case you already knew this and your question is more complex than first reads.
To access the ListItem and add a CheckBox I believe you'd have to switch in to C++ write your own ListItemProvider to update the selected item possibly using a DelegateControl or handling the adding and removing of the control to the scene yourself.
Without a bit more explanation or seeing code its hard to know what your scope problem is and the level of complexity you are looking for.
02-28-2013 10:15 AM
Your second reply is a more accurate answer to my question
In the docs (ListItemComponent), it reads
This class can only be used in QML. In C++, the visuals for list items can be managed using ListItemProvider.
and in the first line of ListItemProvider, it reads
An interface for providing VisualNode objects as items in a ListView.
So I guess ListItemComponent for qml doesn't allow you to control visual node as "items"? So can I conclude that there is absolutely no way for ListItemComponent to be modified from outside (of listview) signal?
02-28-2013 11:10 AM - edited 02-28-2013 11:23 AM
That's the way I read it, and I ended up switching to C++ and writing my own Provider to get around the limitations that seem to be in QML. It's not that difficult and once it's done you get a more workable and understandable level of control of the ListView.
Bite the bullet.
Also I wouldn't say there is no way to modify as you can access the model and the view from within the ListItemComponent just not access from a seperate piece of logic outside of the component.
02-28-2013 11:12 AM - edited 02-28-2013 11:17 AM