04-17-2013 06:48 AM
Not trying to be rude here, but it seems your practice is to make up some code that sort of looks like it might do something like you want, try it, when it fails, post it here and ask what is wrong with it?
I would recommend a different approach. Base your code on real working samples, get them going and then change the code to match what you really want.
Rather than Goggling, I recommend that you start here
and review everything you find. it is a lot, I don't expect you to take it in, but at least you will find the documentation you need and more samples to use.
Returning to this problem, in the code you have supplied, both the ListView and the associated datamodel are supplied by C++. So that doesn't help much in this specific case where the ListView is being supplied by QML. I recommend this: