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. How to make widget use maximum height
Forum Update on Monday, May 27th 2025

How to make widget use maximum height

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 1.9k 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.
  • O Offline
    O Offline
    OpenGL
    wrote on 6 Jan 2021, 07:45 last edited by OpenGL 1 Jun 2021, 07:46
    #1

    I'm using qt creator and designer to create an app, and so far I have in the MainWindow 4 things:

    1. a qtreeview
    2. a group box
    3. another group box
    4. a vertical spacer

    The treeview is to the left and first groupbox is in the upper right corner, and the other box below and the spacer below that group box.

    I selected each group box in turn and clicked "Lay out in a grid" and set "LayoutSizeConstraint" to "SetFixedSize" for them both, so they look very nice and keep their size when resizing the mainwindow.

    Then I selected the central widget and clicked "Lay out in a grid".

    Now the groupboxes are close to eachother and stay in the upper right corner when resizing the mainwindow, and the treeview changes size to fit as much as possible horrizontaly (great!) but how can I get it to scale vertically and use maximum height?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sierdzio
      Moderators
      wrote on 6 Jan 2021, 09:53 last edited by
      #2

      You need to modify sizePolicy of your QTreeView widget and set it to expanding in both directions.

      (Z(:^

      1 Reply Last reply
      2
      • O Offline
        O Offline
        OpenGL
        wrote on 7 Jan 2021, 06:14 last edited by
        #3

        Thanks for the suggestion, but it didn't help. It was already set to Expanding in both directions.

        1 Reply Last reply
        0
        • O Offline
          O Offline
          OpenGL
          wrote on 9 Jan 2021, 02:57 last edited by
          #4

          I solved it by breaking up the layout of the central widget, and putting the widgets to the right (2. 3. and 4.) in a vertical layout, and then add a grid layout in the central widget.

          1 Reply Last reply
          1
          • S Offline
            S Offline
            sierdzio
            Moderators
            wrote on 18 Jan 2021, 13:56 last edited by
            #5

            Nice, thanks for sharing the solution

            (Z(:^

            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