These are two different questions. QTableView and QTableWidget use different methods for setting the background color for rows.
For QTableWidget, when you add or modify the QTableWidgetItem(s) in the rows, you set the color using QTableWidgetItem::backgroundBrush().
If you are using QTableView with a QAbstractItemModel (or proxy), you implement the Qt::BackgroundRole role in the QAbstractItemModel::data() method to set the QBrush used to fill the cells in the row with the appropriate color.
Bookmarks