[PyQt] PyQt Digest, Vol 139, Issue 6

David Cortesi davecortesi at gmail.com
Fri Feb 5 21:25:08 GMT 2016

Date: Fri, 5 Feb 2016 11:42:16 -0500
> From: Steve Waterbury <waterbug at pangalactic.us>
> To: pyqt at riverbankcomputing.com
> Subject: Re: [PyQt] Resizing rows to contents after sort when
>         QSortFilterProxyModel is used
> Any ideas on this one?
> > I'm using a QTableView with a QSortFilterProxyModel.
> > When I first instantiate and populate the
> > table view, I call resizeColumnToContents on each
> > column, followed by resizeRowsToContents on the table
> > view (there are some multi-line cells).
> >
> > However, the sizing to contents is lost when a sort is done

You need to grab some signal that is emitted when the sort completes and
the view has been completely repopulated with sorted data. (Sort indicator
changed might not necessarily correspond to that.) My guess would be
modelReset. I *think* the way the sort filter proxy works is, it tells the
view, modelAboutToBeReset, then modelReset, which makes the view repopulate
itself by calling the data() method of the model.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20160205/8cb2cff6/attachment.html>

More information about the PyQt mailing list