If you have a model with 5 columns and you only want to view 3 in your view, you have to add a subclass of QSortFilterProxyModel(or abstract if you prefer creating some of the functions yourself) between them.
On the subclass you create you need to implement:
bool MySortFilterProxyModel::filterAcceptsColumns(int source_column,
{
//return true for columns you want, else return false...
}
bool MySortFilterProxyModel::filterAcceptsColumns(int source_column,
const QModelIndex &source_parent) const
{
//return true for columns you want, else return false...
}
To copy to clipboard, switch view to plain text mode
See documentation on QSortFilterProxyModel for example on filtering rows. it's the same for columns.
Then use the proxymodel on the view you have.
When accessing data through a selection model on the view you need to use the mapToSource and mapFromSource on the selectionmodel to find the corresponding item in your model. You can also use the QSortFilterProxyModel for sorting and filtering... which is something most applications want to have...
cheers,
Leif
Bookmarks