QTreeView - where to call setIndexWidget() for custom widgets in view
-
Hello,
I want to style my QtreeView to show some more information in each cell.
The result should look kind of this:
I've managed to set the widget by explicitly calling setIndexWidget() on some index.
ItemDelegates do not work for me since I really need the headerData displayed in each cell (it is different from row to row)I want the widgets to be deployed by the view itself when an item is added and removed when an item is removed, or the column count of the item changes however I do not exactly get where to implement this. And how do I connect the widgets to the ItemModel? Is there some example for this??
What I've done so far is adding the setIndexWidget() call to rowsInserted() however this only works for newly added rows and not when the whole model is reset.
And is it somehow possible to only add widgets to items that are visible which might be good for performance reasons??
-
where to call setIndexWidget() for custom widgets in view?
Nowhere.
I want the widgets to be deployed by the view itself when an item is added and removed when an item is removed
You are describing what a delegate does.
ItemDelegates do not work for me since I really need the headerData displayed in each cell (it is different from row to row)
ItemDelegates can do anything to a single cell.
setItemWidget
should only be used when the planets align on a full moon while under the northern lights (aka never).In the absolute worse case you can use a delegate like this one: https://pastebin.com/XrppLZ3m
-