The QTableWdiget is fabulous for simple grid displays. Changing colors, fonts, etc is straightforward.
However, I did not manage to give the grid a ‘tighter’ look with less vertical whitespace. I see that the Qt documentation talks (eg here) about
- margin
- border
- padding
around widgets, but when I set these I only get changes around the entire grid widget rather than inside.
How can I set this (with a style sheet, or hard-coded options) directly to make the QTableWidget display tighter?
The code getting ‘h’ might be unsound. It was just an example. Copy & paste the following rather rudimentary code. Change the value in “setDefaultSectionSize()”, recompile, and run. You should see the difference. Setting this to 10 or 50 yields visible results. In the code above, it is possible QFontMetrics or QFont is messing something up.
You can use whatever you want to get the height, but font size makes the most sense.
EDIT: I don’t know how to format a block of code here… forgive me. 🙂
Edit 2: I fixed that, and the following simple
tighterTable.profilehelps along.
Thanks a big fat bunch for this. BTW: Editing as code is just indenting by four spaces, and/or hitting the button with the little ‘101010’ in the formatting row.