I am using QTableView and QStandardItemModel and I'm trying to colour a row with the font remaining black.
I am using my delegate class's paint method:
void Delegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QBrush brush(Qt::red, Qt::SolidPattern);
painter->setBackground(brush);
}
This does not work at all and it makes the text within each cell transparent. What am I doing wrong here?
[EDIT]
I've used painter->fillRect(option.rect, brush);
as well but it makes the cell background and text the same colour.