qtsortingqt4.7qlistviewqstandarditemmodel

How to Sort ListView Items in Ascending Order?


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.


Solution

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

    Or derive your own model and override sort()