Currently, I see two ways of doing this :
try setting the Qt::BackgroundRole of the designated cell in your model.
Otherwise, you could try defining your own delegate (QStyledItemDelegate) and overriding the
QStyledItemDelegate::paint
QStyledItemDelegate::paint
To copy to clipboard, switch view to plain text mode
method to highlight your cell :
{
int value = index.model()->data().toInt();
if (value > max)
{
painter->fillRect(option.rect, Qt::red);
}
}
void MyDelegate::::paint ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const
{
int value = index.model()->data().toInt();
if (value > max)
{
painter->fillRect(option.rect, Qt::red);
}
}
To copy to clipboard, switch view to plain text mode
(didn't try the code).
Bookmarks