Question

I Tried to Sort my ListView Items in Ascending Order, so i tried with

Model->sort(int Column, Qt::AscendingOrder)

It Works Fine, but I don't like the Qt::AscendingOrder policy. Indeed the function first sorts words beginning with an uppercase character and then sorts the other words starting with a lowercase character. Then it concatenates both results together. For Eg:

My ListView Items are: apple
                       Ball
                       rose
                       cat
                       Orange

And i'm getting the output as:  Ball
                                Orange
                                apple
                                cat
                                rose

Is there any way to customize the Sort Policy? Plz Help me... Thanks in Advance.

Was it helpful?

Solution

Use QSortFilterProxyModel and set sortCaseSensitivity to Qt::CaseInsensitive should do the trick.

Or derive your own model and override sort()

OTHER TIPS

You could apply a trick. Add an extra column with the same labels, but convert them to lower case. Apply sort to this column.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top