PDA

View Full Version : How to change color of single header cell?



Pablo1517
21st November 2014, 12:08
Hello. I have a QStandardItemModel, with QStandardItems in it, all in QTableView.

I have to make certain column headers to be different color and possibly different text. Let's post an example table then:
10756
As you can see first colum and first row font is different because I tried changing color and other stuff in it with this:


QStandardItem *col1 = new QStandardItem("Column 1");
col1->setForeground(Qt::red);
col1->setBackground(Qt::green);
col1->setFont(QFont("arial", 11));

setHorizontalHeaderItem(0, col1);


So changing font works just fine, but colors, nope...
any ideas?

Pablo1517
24th November 2014, 09:26
Nothing :(?

wysota
25th November 2014, 08:03
Maybe the widget style you use does not allow that.