Pergunta

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.

Foi útil?

Solução

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

Or derive your own model and override sort()

Outras dicas

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top