PDA

View Full Version : Setting/getting sortcolumn/sortorder



Michiel
27th May 2007, 20:32
I want to save the sortcolumn and sortorder of a QTableModel->QSortFilterProxyModel->QTreeView with QSettings.

I'm finding it a challenge to set and/or get these two settings from my little setup. I would expect to find a function specifically meant to get and restore these settings, like there is one to get and restore the toolbar-positions.

The actual sorting happens in the QSortFilterProxyModel, doesn't it? But I can't find the functions I need in there.

Any help?

Thanks in advance!

marcel
27th May 2007, 20:38
I don't believe you can.
You should store somewhere ( in the model, the view, or wherever is accessible ), the sort order and sort column. In the model would be best to store it.

When you load it again, just pass the sort column and sort order as you would normally do.

Regards

jpn
27th May 2007, 20:42
You can use QHeaderView::sortIndicatorSection() and QHeaderView::sortIndicatorOrder() to save and QTreeView::sortByColumn() to restore. The header is accessible via QTreeView::header().

Michiel
27th May 2007, 21:39
You can use QHeaderView::sortIndicatorSection() and QHeaderView::sortIndicatorOrder() to save and QTreeView::sortByColumn() to restore. The header is accessible via QTreeView::header().

Works for me. Thanks!

I think they should put those get-functions in the QTreeView. But that's just me. ;)