Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Resize QTableWidget Columns
Qt 6.11 is out! See what's new in the release blog

Resize QTableWidget Columns

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 888 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.
  • G Offline
    G Offline
    goocreations
    wrote on last edited by
    #1

    I've been stuck on this for a while. I have a QTableWidget with 6 columns. If the table is in stretched mode (see below), the entire table width is X pixels.

    @myTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);@

    If I set the columns to fit its content (see below), the table width is Y pixels (where Y < X).

    @myTable->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);@

    I want the table columns to fit their content. After that I want to use the remaining width (X - Y) and evenly distributed over all the columns, so that the ending width is X again.
    So basically I want a table that fits to its content and then "pad" each column with the remaining width (the table must always have a constant width).

    Any ideas on how to do this?

    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