I am trying to figure out how to change the background color of one cell, the changing of the actual text and changing the text alignment is also working correctly, but the background color isn't changing. Any thoughts?

Qt Code:
  1. QVariant FavoriteSqlModel::data(const QModelIndex &index, int role) const
  2. {
  3. QVariant value = QSqlQueryModel::data(index, role);
  4.  
  5. if(index.column() == _statusIdx)
  6. {
  7. int status = value.toInt();
  8.  
  9. switch(role)
  10. {
  11. case Qt::DisplayRole:
  12. if(value.isValid())
  13. {
  14. switch(status)
  15. {
  16. case 0:
  17. return tr("");
  18. case 1:
  19. return tr("Uncopied");
  20. case 2:
  21. return tr("Modified");
  22. case 3:
  23. return tr("Copied");
  24. }
  25. }
  26. break;
  27. case Qt::TextAlignmentRole:
  28. return Qt::AlignHCenter | Qt::AlignVCenter;
  29. //case Qt::BackgroundColorRole:
  30. case Qt::BackgroundRole:
  31. switch(status)
  32. {
  33. case 0:
  34. case 1:
  35. // use the default
  36. break;
  37. case 2:
  38. return QColor(Qt::yellow);
  39. case 3:
  40. return QColor(Qt::darkGreen);
  41. }
  42. break;
  43. }
  44. }
  45.  
  46. return value;
  47. }
To copy to clipboard, switch view to plain text mode