Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QTableWidget Horizontal Header CSS

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?

like image 837
user_123abc Avatar asked Sep 09 '26 15:09

user_123abc


1 Answers

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.

like image 180
alexisdm Avatar answered Sep 12 '26 11:09

alexisdm