I have a table that renders a cell background green or red depending on its value. Here's a picture:

Capture.png

When I select/focus the table row, the green color is lost:

Capture2.png

I would like to keep a greenish color only for the single cell on focus/selection. Perhaps I would make it a slightly darker green color. How would I go about doing this?

Here is my code that renders the cell green or red:

Qt Code:
  1. QVariant ExternalDataSourcesTableModel::data(const QModelIndex & index, int32_t role) const
  2. {
  3. ...
  4.  
  5. if (role == Qt::BackgroundRole)
  6. {
  7. if (index.column() == static_cast<int>(Column::STATUS)) {
  8. if (externalDataSource.getStatus(reason) == "OK") {
  9. return QColor(Qt::green);
  10. }
  11. else {
  12. return QColor(Qt::red);
  13. }
  14. }
  15. }
  16.  
  17. ...
  18. }
To copy to clipboard, switch view to plain text mode