Setting icon to each items head

  • Hi All,

    Now I'm implementing QTreeView with QStandardItem(Model).
    Does anybody know if I can set an icon to the head of each item(row), instead of the default up/down arrow?

    Many thanks in advance for your update!

  • Qt Champions 2018

  • @VRonin Thanks for an update!
    Yes, I'm reading it right now!
    I want to switch the icon from multiple icon list according to the contents.
    SO,,,,, I need to program to switch the stylesheet (eg.QTreeView::branch:open/close), correct?
    Not sure any alternative solution at the moment..


  • Qt Champions 2018

    Are you sure you can't work with just the Qt::DecorationRole? what you want to implement is not easy at all.

    Either you subclass a style and reimplement drawPrimitive for QStyle::PE_IndicatorBranch or use the stylesheet to remove the indicators altogether and paint them over manually subclassing QTreeView and reimplementing drawBranches

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.