Re: General question about Proxy Model
Maurizio Berti <[email protected]>
| Newsgroups | gmane.comp.python.pyqt-pykde |
|---|---|
| Message-ID | <CAPn+-XTXU82TJ-mLhuVT7EF90xqv0dV9KULfy+rYrVKbgn1MsQ@mail.gmail.com> |
Since you're implementing your own model, implementing removeRows() in the source model should be enough, but you have to ensure that its implementation responds as expected: removeRows has to return a bool, and the parent *must* be checked, expecially if you have a tree structure. Also ensure that all basic model functions (index, parent, rowCount, columnCount and data) are correctly implemented. I'd suggest you to give us a minimal example anyway, you might even find out what is wrong in your case. Maurizio Il giorno mar 14 mag 2019 alle ore 21:38 John F Sturtz <[email protected]> ha scritto: > 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 > _______________________________________________ > PyQt mailing list [email protected] > https://www.riverbankcomputing.com/mailman/listinfo/pyqt > -- È difficile avere una convinzione precisa quando si parla delle ragioni del cuore. - "Sostiene Pereira", Antonio Tabucchi http://www.jidesk.net _______________________________________________ PyQt mailing list [email protected] https://www.riverbankcomputing.com/mailman/listinfo/pyqt