QTableView, setting a cell's font and background colour
<p>I am using QTableView and QStandardItemModel and I'm trying to colour a row with the font remaining black. </p>

<p>I am using my delegate class's paint method:</p>

<pre><code>void Delegate::paint(QPainter *painter, const QStyleOptionViewItem &amp;option, const QModelIndex &amp;index) const
{
    QBrush brush(Qt::red, Qt::SolidPattern);
    painter-&gt;setBackground(brush);
}
</code></pre>

<p>This does not work at all and it makes the text within each cell transparent. What am I doing wrong here?</p>

<p>[EDIT] 
I've used <code>painter-&gt;fillRect(option.rect, brush);</code> as well but it makes the cell background and text the same colour.</p>