PDA

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



brixton
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_proxy->invalidate();

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


The above code returns:


false
true


I am actually having trouble hiding columns elsewhere in my code which I how I stumbled on this curiosity.

Thanks for any explanations!

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

brixton
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.

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