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

- 2,595
- 12
- 44
- 83
-
@Ankur's stylesheet solution works, but in this case Windows 10 style disappeared. Are there any more solutions? – Ufx Oct 06 '15 at 08:57
2 Answers
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.

- 3,765
- 3
- 39
- 69
set this stylesheet in tablewidget.
QTableWidget ::section {
border: 1px outset #161618;
}

- 1,385
- 11
- 21
-
It works. But somewhere width is 1px and somewhere is 2px. Can I make same widths? https://i.imgur.com/GLiE9TC.png?1 – Ufx Oct 06 '15 at 08:27
-
1Try this: QTableWidget ::section { border-top: 0px solid #161618; border-left: 0px solid #161618; border-right: 1px solid #161618; border-bottom: 1px solid #161618; } – Ankur Oct 06 '15 at 09:32
-
Thanks! It is much more better than without lines. Now I will try to find solution for keeping Windows 10 headers style but with horizontal lines. – Ufx Oct 06 '15 at 11:00
-
@ Ankur maybe you know solution how to add line here https://i.imgur.com/WdAX4Oa.png?1 ? – Ufx Oct 06 '15 at 11:08
-
1@Ufx , try this QTableView#tableWidget QHeaderView { border-top: 0px solid #161618; border-bottom: 1px solid #161618; } – Ankur Oct 06 '15 at 12:10
-
@ Ankur is it possible to make without these lines https://i.imgur.com/3zWzI30.png ? – Ufx Oct 07 '15 at 06:42