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. Fixed optimal size of QTableView when rows and columns count never change
Forum Updated to NodeBB v4.3 + New Features

Fixed optimal size of QTableView when rows and columns count never change

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 3.1k Views
  • 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.
  • C Offline
    C Offline
    charlesfleche
    wrote on last edited by
    #1

    I'm developing an editor for a a piece of hardware and presenting some parameters as two QTableView. The rows and columns count never change for each table, but one table has 4 columns, the other 3.

    These table should never be resized when the window is resized: another widget will grow (a list a presets), as a space below the tables. The width of the right section of the UI should be driven by the top QTableView (the one with 4 columns).

    Here is what I have now:
    Now

    And this what I'd like to obtain:
    Want

    1. How can I specify that the QTableView geometries should never change after being optimally sized ?

    2. Is there a way to tell the bottom QTableView (the one with 3 columns) to equally size the columns to fill the available space ?

    Many thanks !

    VRoninV 1 Reply Last reply
    0
    • C charlesfleche

      I'm developing an editor for a a piece of hardware and presenting some parameters as two QTableView. The rows and columns count never change for each table, but one table has 4 columns, the other 3.

      These table should never be resized when the window is resized: another widget will grow (a list a presets), as a space below the tables. The width of the right section of the UI should be driven by the top QTableView (the one with 4 columns).

      Here is what I have now:
      Now

      And this what I'd like to obtain:
      Want

      1. How can I specify that the QTableView geometries should never change after being optimally sized ?

      2. Is there a way to tell the bottom QTableView (the one with 3 columns) to equally size the columns to fill the available space ?

      Many thanks !

      VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by VRonin
      #2

      @charlesfleche said in Fixed optimal size of QTableView when rows and columns count never change:

      How can I specify that the QTableView geometries should never change after being optimally sized ?

      tableView->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
      tableView->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
      

      @charlesfleche said in Fixed optimal size of QTableView when rows and columns count never change:

      Is there a way to tell the bottom QTableView (the one with 3 columns) to equally size the columns to fill the available space ?

      tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);

      You can do all the above even in desinger.
      You'll have to put a QSpacerItem below the second table

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      C 1 Reply Last reply
      2
      • VRoninV VRonin

        @charlesfleche said in Fixed optimal size of QTableView when rows and columns count never change:

        How can I specify that the QTableView geometries should never change after being optimally sized ?

        tableView->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
        tableView->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
        

        @charlesfleche said in Fixed optimal size of QTableView when rows and columns count never change:

        Is there a way to tell the bottom QTableView (the one with 3 columns) to equally size the columns to fill the available space ?

        tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);

        You can do all the above even in desinger.
        You'll have to put a QSpacerItem below the second table

        C Offline
        C Offline
        charlesfleche
        wrote on last edited by
        #3

        @VRonin Pefect ! I had to fight a bit with the spacer on the Midi channel row, but apart from that, you were spot on. Many thanks !

        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