Basically, I need to customize the background of a QTableView
modeled by QStandardItemModel
I was able to change the background color of the QTableView
by setting a stylesheet as below, but with this the, the header column background still stays white.
reportTableView = """
#reportTableView{
background-color:#333;
color:#fff;
border:1px solid #555;
}
#reportTableView::section{
background-color:#333;
}
"""
reportContentsWidgetModel = QStandardItemModel(4, 4)
reportColumnNames = ["website", "https://neehack.com", "neehack.com", "pubs"]
reportContentsWidgetModel.setHorizontalHeaderLabels(reportColumnNames)
reportContentsWidget = QTableView()
reportContentsWidget.resizeColumnToContents(0)
reportContentsWidget.setModel(reportContentsWidgetModel)
I tried I.e below, but it is not working:
reportContentsWidgetModel.setData(reportContentsWidgetModel.index(0, 0), QBrush(QColor(255, 0, 0)), Qt.BackgroundRole)