PDA

View Full Version : No Sort Vertical Header



wirasto
30th June 2009, 13:20
By using QSortFilterProxyModel, then when sorting, the sequence of the vertical header in QTableView also changed. How do I not change order number in the vertical header when column sorted ?

http://wirastokarim.files.wordpress.com/2009/06/sc-vheader.png

Sorry, my english is bad

wysota
30th June 2009, 20:57
Reimplement headerData() on the proxy and always return the regular sequence of row numbers.

wirasto
1st July 2009, 01:12
OK, I so confused. Can you give me example code ?

wysota
1st July 2009, 09:56
QVariant myProxy::headerData(int section, Qt::Orientation orientation, int role) const {
if(orientation!=Qt::Vertical || role!=Qt::DisplayRole)
return QSortFilterProxyModel::headerData(section, orientation, role);
return section;
}

wirasto
1st July 2009, 11:54
That's can start from 0

So, i chane like this



QVariant MyProxy::headerData(int section, Qt::Orientation orientation, int role) const {
if(orientation!=Qt::Vertical || role!=Qt::DisplayRole)
return QSortFilterProxyModel::headerData(section, orientation, role);

return section+1;
}


Thank's for your sample code. Solved now.