I am not good enough at python to completely understand what you are doing, but what I think your code is doing is trying to create a tree that nests under columns other than column 0. QAbstractItemModel allows this, but QTreeView does not. Tree views only support nesting under the 0-th column of each row. I am also not sure if you are doing the right thing in the index() method. "row" is relative to the parent index (that is, row = n is the nth child of the parent), whereas "col" is relative to the columns in "row". In addition, you aren't returning an invalid QModelIndex for conditions where either "row" or "col" are not valid. With python's dynamic typing, I don't know what is being returned if the methods falls off the bottom. For example, for "Researcher" and the other single fields in your tree model, the row count is zero for those indices since they have no children. (Assuming you have drawn your tree schematically the way you intend for it to appear in the tree view).
In addition, you must implement parent() correctly. By returning a null index, I don't think your code will work beyond displaying the topmost entry.
Check out the Qt Simple Tree Model example. It's in C++, but mapping that to python should be straightforward.
Bookmarks