
Thus was only one specific model that had this problem, as other models in my app were purely using internal lists and no internalPointer calls.Īlso Erkan, I think your answer was meant for a QTreeWidget where you are dealing with converting between indexes and model items.

Solution was to store my own mapping of the objects as well and manage adding and removing them properly, and then storing only a unique id as the internalPointer to look them up. It would return broken instances of my items. Common Manipulation of QTreeview using PyQT5 published on Maby Author T.Y. Turned out that using internalPointer as the only place to store your object can lead to garbage collection issues and corruption. I just recently had to fix a tricky bug where randomly my model would crash saying that various attributes didn't exist on a custom item I store in my model, when they are part of the subclass implementation. nbassler / treeviewtest.py Created 4 years ago Star 7 Fork 3 PyQt5 TreeView with QAbstractItemModel Raw treeviewtest. That way you are covered if your model stores it's objects in a private list or dict or internalPointer.

You can rate examples to help us improve the quality of examples.
Pyqt5 treeview code#
I wanted to add that you should not use the internalPointer method outside of the internal code of your model. These are the top rated real world Python examples of extracted from open source projects.
