QTableWidget and sorting like int
Hi
I've a QTableWidget TabelaLista, and I set a sorting Enable by:
Code:
TableLista->setSortingEnabled(false);
Now, in one of columns i've a strings like:
Quote:
1/01/2000
2/01/2000
3/02/3000
11/03/2000
etc...
now, I would like to sort only by first part like int (ftom char 0 to char /). Now QT sorting like a string:
Quote:
1/01
11/01
2/01
3/02
I'ld like somthing like:
Quote:
1/01
2/01
3/02
11/01
how do this? Thanks
Re: QTableWidget and sorting like int
create a hidden column where you store only the first (integer) part of the string. And then sort for that column. Or create your own QSortFilterProxyModel and define a proper sort function. (QSortFilterProxyModel::lessThan())
Re: QTableWidget and sorting like int
Thanks, but how connect "signal" on push by sorting on column (example 2) and sort by column 3 (hidden)?
Re: QTableWidget and sorting like int
good point. If the user should be able to sort via the header than it's difficult to catch/suppress the right signal from QHeaderView. Another possibility is to simple subclass a QTableWidgetItem and change only QTableWidgetItem::operator<(). Use you own item for that column. That's not so nice as with a proxy sort model but easier.