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.

2
  • Did you ever get this figured out? I am having this problem right now with Qt 4 May 13, 2013 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, 2013 at 12:42

1 Answer 1

0

This should work:

vHeaderItem->setBackgroundColor(Qt::yellow);
1
  • Yeah, it doesn't (at least for me). Thanks for the suggestion though.
    – Jean-Luc
    Feb 2, 2012 at 10:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.