1

I would like to change the color of a vertical header cell in a QTableWidget.

Here is my (failed) attempt:

QTableWidgetItem* vHeaderItem = new QTableWidgetItem;
vHeaderItem->setBackgroundColor(QColor("yellow"));
ui.tableWidget->setVerticalHeaderItem(r, vHeaderItem);

I have no idea why this wouldn't work.

Jean-Luc
  • 3,563
  • 8
  • 40
  • 78
  • Did you ever get this figured out? I am having this problem right now with Qt 4 – Freedom_Ben May 13 '13 at 22:35
  • From memory, there is a bug, but don't quote me on that. I think if you do a bit more searching, you'll find some posts about this somewhere else on the Qt site. I haven't used Qt in ages and so don't remember to well... Sorry. I think maybe to change the colour you need to change the XML file, but again, I don't fully remember. – Jean-Luc May 15 '13 at 12:42

1 Answers1

0

This should work:

vHeaderItem->setBackgroundColor(Qt::yellow);
Neox
  • 2,000
  • 13
  • 12