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. Having different header width while using QHeaderView::Stretch
Forum Updated to NodeBB v4.3 + New Features

Having different header width while using QHeaderView::Stretch

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 287 Views 2 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.
  • Dummie1138D Offline
    Dummie1138D Offline
    Dummie1138
    wrote on last edited by Dummie1138
    #1

    Hi. I have an application where to the far left is a checkbox and the rest of the table contains text. Like so.

    91ede470-e9eb-4979-a619-ffbb26735a19-image.png

    Another example:

    6d362878-f9f3-4237-b76b-f09afb03d28c-image.png

    I want to resize the far left to something much more narrow, but have the remaining headers retain their ability to stretch, like so.

        ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
        ui->tableWidget->setColumnWidth(0, 30);
    

    According to the documentation on QHeaderView::Stretch, "The size cannot be changed by the user or programmatically." This is why I'm wondering whether there exists a way to retain the header view stretch size.

    Chris KawaC 1 Reply Last reply
    0
    • Dummie1138D Dummie1138

      Hi. I have an application where to the far left is a checkbox and the rest of the table contains text. Like so.

      91ede470-e9eb-4979-a619-ffbb26735a19-image.png

      Another example:

      6d362878-f9f3-4237-b76b-f09afb03d28c-image.png

      I want to resize the far left to something much more narrow, but have the remaining headers retain their ability to stretch, like so.

          ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
          ui->tableWidget->setColumnWidth(0, 30);
      

      According to the documentation on QHeaderView::Stretch, "The size cannot be changed by the user or programmatically." This is why I'm wondering whether there exists a way to retain the header view stretch size.

      Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      There is another overload of setSectionResizeMode that takes a section index. Use it to set section 0 mode to QHeaderView::Fixed and give it a fixed size with resizeSecion.

      1 Reply Last reply
      2

      • Login

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