Search code examples
c++qtqtablewidgetqtstylesheets

How to change the background color of the QTableWidget's vertical header?


I would like to change the colors of a QTableWidget. I am almost getting the result I like, but two areas in the vertical header remain white:

enter image description here

Before writing this post I actually managed to color also the upper left corner, but not the other area. Here is the stylesheet I am using:

QTableCornerButton::section {
    background-color: #8b8d8e;
}

QHeaderView::section {
    color: white;
    background-color: #747678;
    gridline-color: #747678;
}

Solution

  • Finally found the answer myself:

    /*The top-left area is actually a button:*/
    QTableCornerButton::section {
        background-color: #8b8d8e;
    }
    
    /*The lower part of the vertical header:*/
    QHeaderView {
        background-color: #8b8d8e;
    }
    

    The original css I posted (QHeaderView::section) referred only to the header entries, not the header itself.