I am working on understanding trees, working through the simpletreemodel example that comes with Qt. I am working in PySide, not Qt, and while I don't know much c++ I often find it helpful to look at the Qt source code to help me understand what is happening.
I understand indexes a bit (because of a thread here), and now am trying to understand QTreeView, in particular how it paints the initial tree, determines what to draw, when/where it calls model.rowCount() and other methods from my QAbstractItemModel subclass.
I've been looking over qtreeview.cpp and am confused. My first confusion is about what the 'd' class is. I think it is an instance of QTreeView, because starting on line 196 we have:
But there are lots of methods/attributes of d that I cannot find defined anywhere. For instance viewItems seems pretty key, and has many methods (e.g., resize(), clear()) that I'd like to study. Unfortunately I am not sure where viewItems is defined initially, what it means. I have never seen it documented, or used it explicitly in my custom views. In addition to qtreeview.cpp, I searched for it in qtreeview.h, qabstractitemview.cpp, and qabstractitemview.h.Qt Code:
{ d->initialize(); }To copy to clipboard, switch view to plain text mode
So I seem to be having a problem similar to when I was tracking down the definition of createIndex. Namely, figuring out where to find the relevant source code.
More generally, anyone please let us know if you have seen a good nuts 'n' bolts explanation of how QTreeView works. I have found high-level descriptions of what is going on (e.g., the view uses indexes to determine what to paint to the screen), but I really want to know more under the hood. I have started putting print commands in the model for all the methods (e.g., rowCount), but this has made me even more confused: for instance, sometimes it is calling rowCount with input from a parent index from a row that is way below my selection.
Thanks for reading.
Bookmarks