View Full Version : Need to call QTableView::invalidate() before hiding columns

9th December 2010, 19:22
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.

m_view->setColumnHidden(5, true);
qDebug() << m_view->isColumnHidden(5);


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!

9th December 2010, 19:50
It's likely you made some mistake in your reimplementation. And possibly the hiding is done some time later.

9th December 2010, 19:59
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.

9th December 2010, 20:27
I have no idea, I haven't seen your code.