Grouping ListView elements
-
wrote on 4 Sept 2012, 09:22 last edited by
I have a listview with group id 1 and 0. I need to group 0's and 1's separately. Any idea how to do it? Do I need to create another ListModel and add these elements accordingly or can i re-arrange my current ListView.
Thanks in advance
-
wrote on 4 Sept 2012, 09:52 last edited by
What do you mean with 'group' exactly? Do you need to just sort them so they stay together, or do you really need to visually group them?
-
wrote on 4 Sept 2012, 10:08 last edited by
I need to sort them in one order, parameter with id 0 at first and then parameter with id 1. Thanks
-
wrote on 4 Sept 2012, 10:13 last edited by
am unable to get the logic to solve it with index. for ex. i have 6 elements with id 0 1 2 2 1 0 in the following manner i need to display it as 0 0 1 1 2 2. I hope now it is clear
-
wrote on 4 Sept 2012, 10:14 last edited by
Sure, that is very possible. Use a [[doc:QSortFilterProxyModel]] between your model and your view, and sort on the appropriate role and column. If you need to sort within the groups too, you will have to resort to subclassing and reimplementing the virtual bool lessThan ( const QModelIndex & left, const QModelIndex & right ) const function.
-
wrote on 4 Sept 2012, 10:20 last edited by
Am working completely in qml so am not used to these functions.. do u have an example
-
wrote on 4 Sept 2012, 10:21 last edited by
Its toooo complicated for me as a beginner.
-
wrote on 4 Sept 2012, 10:22 last edited by
In that case, you should have posted in the appropriate forum. Now, you give no clue whatsoever as to the technology you are using. I will move this topic there.
-
wrote on 4 Sept 2012, 10:23 last edited by
[quote author="Julie1986" date="1346754100"]Its toooo complicated for me as a beginner.[/quote]
Please don't followup post so rapidly. Just edit your previous post instead.
-
wrote on 4 Sept 2012, 10:25 last edited by
[quote author="Julie1986" date="1346754049"]Am working completely in qml so am not used to these functions.. do u have an example[/quote]
For QML, did you take a look at setting the section.property for the ListView?
-
wrote on 4 Sept 2012, 10:37 last edited by
ya I tried to use that but it does not work according to my rule:(
1/11