Frage

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.

War es hilfreich?

Lösung

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

Or derive your own model and override sort()

Andere Tipps

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top