1 Attachment(s)
Issue with ProxyModel with tableview and VerticalHeader
Hi,
Suppose using ProxyModel/Model/View.In tableView whenever the filtering occurs the numbering column(vertical Header) of tableview will filter too.
I want to have sequence of proxymodel rows in numberingColumn(vertical header) instead of sourceModel when filtering occurs. see this:
Attachment 8941
I've shown with red rectangle :)
How can i do that?
Re: Issue with ProxyModel with tableview and VerticalHeader
Re-Implement QAbstractItemModel::headerData() in the proxy model, and make use of signal QAbstractItemModel::headerDataChanged(), when ever filtering / sorting is applied.
Re: Issue with ProxyModel with tableview and VerticalHeader
Thanks Reddy for reply,
What's the deal with headerData() ? I've thought that it must be setHeaderData??!!!
Anyway, how can i do that in headerData method?
Re: Issue with ProxyModel with tableview and VerticalHeader
A trivial implementation will look like
Code:
{
Q_OBJECT
public:
explicit SortFilterProxyModel
(QObject * parent
= 0) {
;
}
QVariant headerData
(int section, Qt
::Orientation orientation,
int role
= Qt
::DisplayRole) const {
if((orientation == Qt::Vertical) and
(role == Qt::DisplayRole) )
return section + 1;
return sourceModel()->headerData(section, orientation, role); //<<<<<< TODO: Make sure sourceModel() is valid
}
};
Re: Issue with ProxyModel with tableview and VerticalHeader
Thanks, but i've already tired that! I think the default implementation of Qt is set to return section!
Re: Issue with ProxyModel with tableview and VerticalHeader
Quote:
Thanks, but i've already tired that!
Does that mean your problem is solved?
Quote:
I think the default implementation of Qt is set to return section!
No, the default implementation of QSortFilterProxyModel::headerData() will return the section number from the source model. If you need to have continuous numbers even after applying filters, then you need to re-implement it.
Re: Issue with ProxyModel with tableview and VerticalHeader