Re: QTreeView + sort + delete = crash

Kyle Altendorf <[email protected]>
Newsgroups gmane.comp.python.pyqt-pykde
Message-ID <[email protected]>
On 2019-05-05 21:52, John F Sturtz wrote:
> [3]
> Regarding passing the view to the model:
> 
> The reason I did this is because, once an item in the tree is edited, I 
> wanted to make it the current item (lines 224-226).  setCurrentIndex() 
> is a view-level method, so I needed a reference to the view to invoke 
> it (or thought I did).  I've bumped into this several times, and always 
> 'solved' it this way (though I never did _quite_ feel like it was the 
> right thing to do).
> 
> What would be considered the 'right' way to handle this?  Should I be 
> connecting a signal to the setCurrentIndex() slot and emitting that?

Maybe dataChanged()?  I don't do this and didn't test it though.

https://doc.qt.io/qt-5/qabstractitemview.html#dataChanged

If not that then at least use a signal/slot, yeah.  The signal/slot 
option would make it more controllable independent of existing semantics 
around dataChanged(), is naturally expandable to multiple views or 
optional per view, etc.

Cheers,
-kyle
_______________________________________________
PyQt mailing list    [email protected]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.