[Qt-interest] GUI, Qt, Sorting, QTableWidget, NO sorting even after setSortingEnabled()

Andre Somers andre at familiesomers.nl
Wed Aug 4 20:37:01 CEST 2010


Op 4-8-2010 20:19, Mandaya Prakash schreef:
>
> Hi All,
> My company has now started usin Qt and I am having some probelm with 
> QTableWidget sorting.
>
> I have a QTableWidget. And I fill it with some QTableWidgetItem, 
> initiated by simple QString,
> actually, just a number like 1,2,10, etc. The problem is that when I set
> tableWidget->setSortingEnabled(true); and then sort by this column, the
> order is 1,10,2..., looks like it's compared as string.
>
> I don't want to change the code a lot (e.g., creating a customized
> sub-class) to make it sort correctly. So is there any option of the
> table/item that I can just set to make it work?
> Thank you in advance
>
Did you try not setting a string, but a number to begin with in the 
QTableWidgetItem?

André




More information about the Qt-interest-old mailing list