Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Resize QTableWidget Columns

    General and Desktop
    1
    1
    764
    Loading More Posts
    • 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
      goocreations last edited by

      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 Reply Quote 0
      • First post
        Last post