I have a table widget with two column header in a dialog that looks like this:
There is a separation between the column headers named "Index" and "Label", but there is no separating border between these header and the row below them. How can this be added?
Say the table is instantiated as:
table = QTableWidget(6, 2, self)
I know that I can get the first horizontal header as a QTableWidgetItem by doing headerItem = table.horizontalHeaderItem(0)
modify some properties and set it back, but I'm unsure of what properties to set or if there is a more straightforward approach.
EDIT:
If I extract the header and set the style, shadow, and line width properties of its underlying frame via:
header = table.horizontalHeader()
header.setFrameStyle(QFrame.Box | QFrame.Plain)
header.setLineWidth(1)
table.setHorizontalHeader(header)
I end up with something that looks like this:
This way a border does show up around the header. This could be done for each header item separately, but there are a couple of concerns:
- The border extends past the width of the cells below
- I'd still have to match the color of the frame to the existing lines for this to look somewhat decent.
- It appears that the vertical line that separates "Index" and "Label" is shifted in relation to the line separating the cells below (unless my eyes are playing tricks on me).
Is there a more 'built in' way to do this?