[PyQt] Resizing rows to contents after sort when QSortFilterProxyModel is used
Steve Waterbury
waterbug at pangalactic.us
Wed Feb 3 18:15:26 GMT 2016
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). That much works
fine when the table is first set up.
However, the sizing to contents is lost when a sort is
done, and in googling for solutions I came across a
suggestion to connect the horizonal header's
'sortIndicatorChanged' signal to the table view's
'resizeRowsToContents', which seems reasonable but
doesn't work properly in my case --
I suspect that is because of the remapping done by the
proxy model. Is there an easy way to make
'resizeRowsToContents' aware of the sorted row mapping?
(Perhaps something analogous to proxy's 'mapToSource',
which I am using to get the correct row selections?)
Hope this question is clear enough -- if not, let me know
and I'll include some code.
Thanks!
Steve
More information about the PyQt
mailing list