Ufx
Ufx

Reputation: 2695

QHeaderView has no horizontal lines in Windows 10

enter image description here

QTableWidget headers have no horizontal lines in Windows 10. How can I fix it?

Upvotes: 4

Views: 2447

Answers (2)

Arnaud
Arnaud

Reputation: 3741

I had the same problem. It can be solved with the following style sheet on the table view/widget:

if(QSysInfo::windowsVersion()==QSysInfo::WV_WINDOWS10){
    setStyleSheet(
        "QHeaderView::section{"
            "border-top:0px solid #D8D8D8;"
            "border-left:0px solid #D8D8D8;"
            "border-right:1px solid #D8D8D8;"
            "border-bottom: 1px solid #D8D8D8;"
            "background-color:white;"
            "padding:4px;"
        "}"
        "QTableCornerButton::section{"
            "border-top:0px solid #D8D8D8;"
            "border-left:0px solid #D8D8D8;"
            "border-right:1px solid #D8D8D8;"
            "border-bottom: 1px solid #D8D8D8;"
            "background-color:white;"
        "}");}

This is C++ code but it should be easy to adapt to your needs.

Note1: The background-color and padding are unfortunate but they are necessary to make our custom rendering looks like the default one.

Note2: The color of the border is the color of the grid on my system. I did not use the color of the default header.

Note3: The QTableCornerButton::section part is necessary to add the missing border below the top left corner. If the vertical header is not visible, the missing line is invisible too.

Note4: If (like me) you find that the ugly grey rectangle below the name of your rows needs fixing, just add QHeaderView{background-color:white;} to your style sheet.

Hope this helps.

Upvotes: 4

Ankur
Ankur

Reputation: 1473

set this stylesheet in tablewidget.

QTableWidget ::section {
   border: 1px outset #161618;
}

Upvotes: 1

Related Questions