Search code examples
c++qtqwidget

How to fix the size of my Qt window?


I have a QWidget, the parent class for all my other widgets. In Qt Designer I set width = 600 and height = 400 for the QWidget. My size Policy is [Fixed, Fixed, 0, 0].

But if I start my the application the QWidgets size is at least 2500*400. How could I fix the size at application start to 600*400?


Solution

  • The size policy on a toplevel layout is meaningless if you don't set the size constraint as well via QLayout::setSizeConstraint. It is the size constraint that links the layout to the toplevel widget's size.