QTableWidget Horizontal Header CSS

3.3k views Asked by At

I'm trying to style a QTableWidget using the latest Qt SDK (4.7.4). From Googling, I've seen that I need to do something like this:

QHeaderView::section {
    background: red;
    /* ... */
}

Inside of Qt Designer, this produces red headers for the columns and rows. However, inside of the actual program, the vertical section headers show up correctly but the horizontal column headers are unaffected. Why is this?

1

There are 1 answers

1
alexisdm On BEST ANSWER

It seems you need to set the style sheet before you call QTableWidget::setColumnCount, but you can't change the order of these calls for the generated code.

As a workaround, you can put the style sheet in your QTableWidget parent widget or in the QApplication.