3
votes

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
Could you give more details about what working correctly or not means, along with an example of the stuff you have in your stylesheet ?alexisdm
Sure thing. If the edits aren't clear enough I can provide screenshots.user_123abc

1 Answers

3
votes

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.