Background color of headers doesn't change in QAbstractTableModel
Solved
General and Desktop
-
So I Have this code and basically I would like to change the color of each section based on some property, but this doesn't work.
QVariant TableModel::headerData(int section, Qt::Orientation orientation, int role) const { if (role == Qt::BackgroundRole && *somecondition*) { return QBrush(CHANGECOLOR); }
Any Idea?
-
I think it's a style issue as explained here: https://doc.qt.io/qt-6/stylesheet.html
"For example, it might be tempting to set the QPalette::Button role to red for a QPushButton to obtain a red push button. However, this wasn't guaranteed to work for all styles, because style authors are restricted by the different platforms' guidelines and (on Windows and macOS) by the native theme engine."Which OS & Qt style do you use?
-