Need to call QTableView::invalidate() before hiding columns
I'm having trouble understanding why I need to call QTableView::invalidate() before I can hide columns in the view.
Here m_proxy is a subclassed QSortFilterProxyModel with a reimplemented filterAcceptsRow and m_view is just QTableView.
Code:
m_view->setColumnHidden(5, true);
qDebug() << m_view->isColumnHidden(5);
m_proxy->invalidate();
m_view->setColumnHidden(5, true);
qDebug() << m_view->isColumnHidden(5);
The above code returns:
I am actually having trouble hiding columns elsewhere in my code which I how I stumbled on this curiosity.
Thanks for any explanations!
Re: Need to call QTableView::invalidate() before hiding columns
It's likely you made some mistake in your reimplementation. And possibly the hiding is done some time later.
Re: Need to call QTableView::invalidate() before hiding columns
Hi Wysota,
In which reimplementation could there be a problem? I have reimplemented QAbstractItemModel. Could there be something there which is causing the problem?
Hiding columns works perfectly after running the invalidate() but the previous calls to hideColumn(int) or setColumnHidden(int, bool) are lost.
Re: Need to call QTableView::invalidate() before hiding columns
I have no idea, I haven't seen your code.