[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: Re: [PyQt] Resizing rows to contents after sort when QSortFilterProxyModel is used
From: Steve Waterbury <waterbug () pangalactic ! us>
Date: 2016-02-16 5:11:08
Message-ID: 56C2AF6C.3080908 () pangalactic ! us
[Download RAW message or body]
OMG! Finally stumbled across the answer tonight while reading about
QAbstractItemModel ... it has a signal I hadn't noticed before:
layoutChanged() -- all I had to do was connect that signal of
my QSortFilterProxyModel to my tableview's resizeRowsToContents,
boom, done! Table view is pretty after the sort -- woo!
Note to self: RTFM (as always ... but in all fairness, it's a
*big* FM ... ;)
Hope this is useful to someone else.
Cheers,
Steve
On 02/12/2016 01:21 AM, Steve Waterbury wrote:
> On 02/12/2016 01:17 AM, Steve Waterbury wrote:
>> On 02/05/2016 04:25 PM, David Cortesi wrote:
>>> From: Steve Waterbury <waterbug@pangalactic.us
>>> 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.
>>
>> Seemed like a logical approach but doesn't work -- thanks anyway.
>> I guess I will have to implement the sort myself and refresh the
>> view. I'm rather surprised that Qt doesn't handle this rather
>> simple scenario!
>>
>> Steve
>
> Oops -- re-sending to correct the subject ... a little list
> etiquette: never reply to a "digest" message without fixing
> the subject! ;)
> _______________________________________________
> PyQt mailing list PyQt@riverbankcomputing.com
> https://www.riverbankcomputing.com/mailman/listinfo/pyqt
_______________________________________________
PyQt mailing list PyQt@riverbankcomputing.com
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic