I been searching for how to set a color on a specific cell on a qtableview.
Currently ,I am using the qt example frozen column to see how to set a color on a particular cell.
I search on the forums about how to tell to use qitemdelegate or qstyleitemdelegate to paint the background or foreground cells but no valid.
Could someone enlighten me or show an example on the code how I should go about it.
The fastest way I can think about is using the setData
method of a standard item:
QStandardItemModel model;
QStandardItem item;
item.setData(QBrush(Qt::gray), Qt::BackgroundColorRole); //background color
model.setItem(x, y, &item);
In this example you set the background color. Different roles (to pass as the second argument) are described here