Grouping ListView elements
-
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
-
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?
-
I need to sort them in one order, parameter with id 0 at first and then parameter with id 1. Thanks
-
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
-
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.
-
Am working completely in qml so am not used to these functions.. do u have an example
-
Its toooo complicated for me as a beginner.
-
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.
-
[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.
-
[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?
-
ya I tried to use that but it does not work according to my rule:(