PDA

View Full Version : Setting the background color of a header in TableView



sunilqt
24th September 2010, 23:25
I have subclassed QAbtractTableModel and am using a standard QTableView in QT Designer. In implementing the headerData() routine for the model, I find if I return a value for Qt::ForegroundRole, the header text shows up in a different color as I expect it to, but with BackgroundRole, nothing happens. With the data() routine, both Foreground and Background work and the colors in the cells show up. I saw a thread from a couple of years ago suggesting this may be a problem with Windows styles and that stylesheets were the work around, but it's unclear to me where one would even apply the style sheet and how (i.e. is it in the model or the view and what do I do in either case). In any case, the behavior of headerData() is inconsistent and I shouldn't have to use this workaround. Any help appreciated.

Sunil

fvsc
13th April 2013, 14:06
Hve you found a solution because I have the same problem.