PDA

View Full Version : scroll on QAbstractItemView layout changes



ibex
29th November 2009, 23:26
I would like to call scrollTo(currentIndex()) after a view has done a layout following a layoutChanged signal from the model but can't see a way to queue this. I can't connect to the same model signal since it would be likely to scroll before the layout is complete. The layout functions of the views are private or non-virtual and I can't see how else to determine when the layout is complete. I'm sure I'm missing something obvious here since it must be a common requirement.

In my case I am using a QListView and am emitting layoutChanged() when the icons returned by the Qt::DecorationRole have changed size.

thanks.

ibex
21st November 2010, 22:54
Looks like overriding QAbstractItemView::updateGeometries() introduced in Qt4.4 to do the scrollTo() is the answer. I'm not sure it is the correct way but it seems to work.