PDA

View Full Version : QTable Sorting



mromey
23rd April 2009, 07:22
So I am building a custom application to manage a stack of items. I have reserved the first row of the table for totaling the values of all the proceeding data in the other rows and columns. Up until this point I haven't needed to turn on the enable sorting option for QTable.

Was hoping somebody could offer some UI suggestions to help me force a specified row to always be at the top of the row list after changing the sort order. I though I might find some signal associated with the sorting order being changed but really didn't find much.

Was even thinking of possibly doubling the size of the header then drawing a another table on top of half of the header that looks like one row, Then filling it with the necessary data to look like a totaling bar. The big issue with this is that the sorting icon would be hidden.

Another option would be to have one Qtable with a header and totaling bar control the sorting of another QTable that conatins the data.

Not sure if any of these solutions are feasible or worthwhile. Any suggestion would be a great help.

-Romey

Lykurg
23rd April 2009, 08:28
Hi, just a quick guess if you use QTableWidget. Subclass and:

void MyTableView::sortByColumn ( int column, Qt::SortOrder order )
{
QTableView::sortByColumn ( column, order );
// here set your fix line back to top.
}


Do the same for QTableWidget::sortItems().