Thanks Volker,
The delegate by default does not draw the branch part of the row, only the column data part (red, green and cyan parts on the pic), so changing bg color in paint options isn't enough (btw. bg color is for some strange reason set to RGBA {1,1,1,0} there so the way to get it is from index bg color role).
Anyway Your suggestion was close enough to lead me to this solution:
class MyDelegate: public QStyledItemDelegate
{
public:
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QStyledItemDelegate::paint(painter, option, index);
if(index.column() == 0)
{
QRect branchRect(0, option.rect.top(), option.rect.left(), option.rect.height());
painter->setCompositionMode(QPainter::CompositionMode_Multiply);
painter->fillRect(branchRect, index.data(Qt::BackgroundColorRole).value<QColor>());
painter->setCompositionMode(QPainter::CompositionMode_SourceOver);
}
}
};
As I imagine this is not 100% correct. Overpainting the branch area in items paint event will not work if on some platforms branches are drawn AFTER the items themselves, but I assume this won't happen in any sane implementation.
Of course, as Everett McGill said "assumption is the mother of all f**kups", but hey, it works on my machine :)
Thanks a bunch again.