Change selected row background color in StyledTableItemDelegate
General and Desktop
1
Posts
1
Posters
578
Views
1
Watching
-
Can't change background color of a selected row. Selection is always in default ubuntu style. How can I change this?
Here is my function paint. As you can see, I try to set the background using this: viewOption.backgroundBrush = QBrush(QColor("#000000"));
@void StyledTableItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QPalette pal = option.palette;
QStyleOptionViewItem viewOption(option);if (option.showDecorationSelected && (option.state & QStyle::State_Selected)) { viewOption.backgroundBrush = QBrush(QColor("#000000")); } viewOption.palette.setColor(QPalette::Text, "#6bc74c"); viewOption.font = QFont("arial", 10); if(index.column() == 1) { viewOption.displayAlignment = Qt::AlignLeft; } else if (index.column() == 2) { viewOption.displayAlignment = Qt::AlignRight; } QStyledItemDelegate::paint(painter, viewOption, index);
}@