Qt QTableWidget Header Color

805 Views Asked by At

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.

1

There are 1 best solutions below

1
On

This should work:

vHeaderItem->setBackgroundColor(Qt::yellow);