tl;dr
I am a PyQt user (Python binding of Qt), and am trying to figure out how Qt natively draws trees in QTreeView, as I am trying to recreate it using a custom delegate (QStyledItemDelegate applied to my view) just for instructive purposes. More specifically, I am viewing a QStandardItemModel using a QTreeView, and want to see the guts of the delegate that is used by default, but am having trouble finding the default 'paint' method. Is there a link to it?
Details
I am not very good at C++ (I'm a Python guy), and am having trouble figuring it out: I have been looking over the code at qtreeview.cpp but haven't actually found anything explicit where, for instance, the text is drawn corresponding to a particular item.
Line 1389 has the `drawTree` method, which calls drawRow on line 1442:
drawRow(painter, option, viewItems.at(i).index);
drawRow(painter, option, viewItems.at(i).index);
To copy to clipboard, switch view to plain text mode
drawRow is defined starting on line 1473. Therein, I think we are reaching the guts, e.g., line 1679:
d->delegateForIndex(modelIndex)->paint(painter, opt, modelIndex);
d->delegateForIndex(modelIndex)->paint(painter, opt, modelIndex);
To copy to clipboard, switch view to plain text mode
This suggests to me that that the delegate for the item associated with `modelIndex` is defined within `delegateForIndex`. But I have now hit the limits of my sleuthing, and am having trouble finding where this delegate, and its paint operation in particular, is defined.
Any hints?
============
Cross posted:
http://stackoverflow.com/questions/3...treeview-in-qt
Bookmarks