Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. How to tune precisely the height of a QTableWidget according to header & row heights
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

Scheduled Pinned Locked Moved Unsolved Qt for Python
1 Posts 1 Posters 329 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    Qoissi
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved