[Interest] ItemModel persitantEditors and QSortFilterProxy

Daniel Price daniel.price at fxhome.com
Fri Aug 31 11:51:09 CEST 2012

I have a QAbstractItemModel-based tree view which uses persistentEditors exclusively (supplied by an attached styled item delegate).

I intercept the expand and collapse signals in the QTreeView to call openPersistantEditor/closePersistantEditor and this works fines.

I've added a QSortFilterProxy subclass with a custom filterAcceptsRow() between the view and the model to (a) filter the visible items based on a search string and (b) optional hide items that have not been edited by the user (a check box toggles this on and off). The sort/filtering works but I need to re-create the persistent editors as the proxy makes rows visible again.

The QTreeView has a rowsInserted protected virtual which I re-implement to call openPersistantEditor. This gets called when the proxy re-inserts rows that match the filter string (using the default filter behaviour).

But if I uncheck the 'show user edited items' checkbox, the proxy puts back those items but I get no notifications in the QTreeView and no signals from the proxy when this happens so they appear without their editors. Only updateGeometry is called. I was expecting the rowsInserted signal to be emitted but it is not.

So how can I get notification from the proxy filter when it shows rows that match the criteria in my custom filterAcceptsRow?

This email is confidential. It may also be privileged or otherwise protected by work product immunity or other legal rules. Errors and Omissions Excluded. If you are not the intended recipient please notify the sender. Please delete the message from all places in your computer where it is stored. You should not copy the email or use it for any purpose or disclose its contents to any other person. To do so may be unlawful. Email is an informal means of communicating and may be subject to data corruption accidentally or deliberately. For this reason it is inappropriate to rely on advice contained in an email without obtaining written confirmation of it first.

FXhome Limited is a limited company registered in England and Wales. Registered number: 04172812. Registered office: Suite 4 St Giles House, 27 St Giles Street, Norwich, Norfolk, NR2 1JN, U.K.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120831/2ab574e7/attachment.html>

More information about the Interest mailing list