Qt 6.11 is out! See what's new in the release
blog
How to tune precisely the height of a QTableWidget according to header & row heights
-
Hello,
I would like to tune dynamically and in a cross platform compatible way the height of a QTableWidget so that:
- No row is "cut" at the bottom of the table and scrolling is smooth (row separators do not move while scrolling).
- Last row bottom separator in the table matches exactly table bottom boundary.
- No scrollbar appears if the table has a number of rows that can fit precisely within the height of the table.
Assuming all rows have the same height, I thought a simple computation based on
- Header height: table.horizontalHeader().height().
- Plus a wished visible number of rows multiplied by table.rowHeight(0).
would make it, but I need for example on Windows to add 4 more pixels to that result to get the behavior I want, and on other platforms this is different. And sometimes it is even dependent on some OS setup.
Would you have any hints to compute the exact table height I need in a clean & cross-platform way?
Thanks a lot for your help.