QTreeView, QStandardItemModel and StyleSheet - Customizing Item

A tree is created on the basis of QTreeView, with different background colors, but the general style of the app is Flat Design. Therefore, all 3D gradients must be replaced with a uniform background. setStyleSheet can be set, but in this case the background color parameters set in the model are ignored.

I have tried to do it via QStyledItemDelegate but it doesn't work.

I ask for advice in the implementation of which way to go.

enter image description here

class StyledItemDelegate: public QStyledItemDelegate
{
public:
    using QStyledItemDelegate::QStyledItemDelegate;
//    QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override {
//        QWidget * widget = QStyledItemDelegate::createEditor(parent, option, index);
//        QPalette pal(widget->palette());
//        pal.setColor(QPalette::HighlightedText, QColor(Qt::green));
//        pal.setBrush(QPalette::Highlight, option.palette.highlight());
//        widget->setPalette(pal);
//        return  widget;
//    }
    virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
    {
        QStyleOptionViewItemV4 editedOpt = option;
        //editedOpt.font = QFont("Arial", 23, 500);
        QStyledItemDelegate::paint(painter, editedOpt, index);
        QBrush brush(Qt::red, Qt::SolidPattern);
        //painter->setBackground(brush);
        initStyleOption( &editedOpt, index );
        QApplication::style()->drawControl(QStyle::CE_ItemViewItem, &editedOpt, painter, nullptr);
    }
protected:
    void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const override{
        QStyledItemDelegate::initStyleOption(option, index);
        option->palette.setColor(QPalette::HighlightedText, QColor(Qt::red));
        //option->palette.setColor(QPalette::Text, QColor(Qt::red));
        QColor background = QColor(Qt::green);
        QBrush brush(Qt::red, Qt::SolidPattern);
        //option->backgroundBrush = brush;
        //option->palette.setBrush(QPalette::Active, QPalette::Window, background);
        //option->palette.setColor(QPalette::All, QPalette::Window, background); // Active
    }

};