Glaring flaw in drawing grid lines for QTableWidget
mfeemster last edited by
This is part question, but mostly a bug report. I'd really like the Qt developers to see this.
When using a QTableWidget, the user has the option of enabling the drawing of grid lines. I've found that Qt draws them in a very naive way that is counter intuitive and most likely not what the majority of users want.
It draws all lines, even the beginning and end ones! Meaning, it draws lines above the first row and below the last row. It also draws to the left of the first column and to the right of the last column. This has the effect of putting an additional border inside of the specified border. This extra border becomes very noticeable when changing the background color of a cell.
I can't think of any scenario where a user would want this behavior. I propose that grid lines only be drawn for the inner rows and columns of a table, and not the outer most ones.
To further complicate matters, there is a bug on top of this bug.
When drawing the upper most grid line for a row, it gets shown if the vertical scroll mode is per-item, but hidden if it's per-pixel. Changing the scroll mode should have no effect on how grid lines are drawn.
My workaround is this:
-Set all scroll modes to per-pixel. This has the effect of hiding the top grid line.
-Make the height of the table one pixel less than it should be. This has the effect of hiding the bottom grid line.
(Left grid line seems to be hidden ok, right is still shown with no workaround.)
-Shrinking the size has the undesired side effect of making the table shift up or down by one pixel if the user scrolls the mouse wheel over the table.
-Workaround the scroll problem by subclassing QTableWidget, installing an event filter on the viewport, and ignoring the mouse wheel event.
My question is, is there any other way to get rid of those pesky outer grid lines other than the double layered hack that I've done?
Otherwise, this post is mostly informational for anyone who has suffered through trying to get your table to look right, and also to hopefully serve as a bug report for Qt developers since I'm not sure how to file a bug.
Hi and thank you for providing these informations.
The forum is not the best place to report bugs, most Qt developer rather follow the mailing list. "Here":http://qt-project.org/wiki/ReportingBugsInQt you can find the information you need to report these bugs.
Hope it helps