[PyQt] General question about Proxy Model

John F Sturtz john at sturtz.org
Tue May 14 20:37:30 BST 2019


Hi again.

I'm the one who started the QTreeView + sort + delete = crash thread on May 8th.  In response to assistance from Kyle and Florian, I've re-implemented to use a QAbstractItemModel with associated QSortFilterProxyModel.

On the whole, that seems to be working pretty well, but there's one thing (well, at least one) I haven't been clear on despite poring over what documentation I can find.  I can post the test code again if it will help, but I think this is more of a general question:

If I have both a source model and also a proxy, and I'm modifying the view in a way that changes the structure (deleting a row, in the current case I'm working on), should I be overriding removeRows() for both the source model and the proxy, and calling beginRemoveRows()/endRemoveRows() in both cases?

I guess that seems to make sense to me, and my initial testing suggests it's so, as it seems to work (whereas if I don't do that, I either get a crash, or a message something like QSortFilterProxyModel: inconsistent changes reported by source model).

Same for inserting rows?  Just checking to see if I'm thinking right here.

Thanks!

/John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20190514/775a6f95/attachment.html>


More information about the PyQt mailing list