When using QHeaderView::ResizeToContents on a QTableView with a fairly large model, hiding the QTableView becomes very slow (which is very annoying if the view is part of a QTabWidget).
The problem seems to be related to
though I have not tested it with QTreeWidget/QTreeView. Sample code (partially taken from the #5003) attached. With resize mode Stretch, hiding the view is very fast, with resize mode ResizeToContents it takes > 2 seconds.
A backtrace shows that QHeaderView::resizeSections() is called on hide, which causes a call to QTableView::sizeHintForColumn(). There the lines
if (!isVisible() || bottom == -1) // the table don't have enough rows to fill the viewport
bottom = d->model->rowCount(d->root) - 1;
cause all rows of the model to be checked, which is of course slow for large models (and seems kinda pointless if the view is not visible anyway...)