Theodore Tang
Theodore Tang

Reputation: 1021

Layout management in Qt

I have a small program which contains a QGroupBox with other widgets like this: enter image description here

I tried many ways to manage the size of the QGroupBox to make the height as the same as the rest of the parts. Except for the way of using setMaximumHeight, because I want the size to change dynamically with the window size too. what else can I do to manage the layout?

Upvotes: 0

Views: 193

Answers (1)

Martin Hennings
Martin Hennings

Reputation: 16846

Right now there are three items in a layout. The layout will try to fill the available space. QLineEdit and QSpinBox (or whatever your second widget is) have SizePolicy.vertical == fixed, so all extra space goes to the QGroupBox.

You have these choices:

  • Add a vertical spacer as fourth item below the groupbox to your layout.
  • Set maximum height of your groupbox - then the remaining space will be evenly spaced between the items.
  • Adjust the size of your window / widget / dialog (in Qt Designer or via code).

Upvotes: 1

Related Questions