Reputation: 8531
I want the user to be able to vertically resize the Window but I'm unsure how I would do this. I have selected my root object (View of type QWidget
) in Qt Creator but I do not see an option to allow users to vertically resize the object. Does this have to be done through code?
Upvotes: 1
Views: 223
Reputation: 11575
By default, if a QWidget
is the top-level window you are able to resize it given that the minimumSize
and maximumSize
are different since they indicate the range of resizing.
If you want to let the user to resize vertically only, then you just have to set both minimumWidth
and maximumWidth
to the same value (probably to the current width of your QWidget
). Qt will take care of indicating the underlying windows manager the rest.
You can do it in the Designer or programmatically using the setMinimumWidth
and setMaximumWidth
methods. Edit: As mentioned in a comment, there is a setFixedWidth
method that simplifies this operation (and make it more explicit in your code).
Of course, you can play with the combinations such as setting a minimum width (or height, or both -minimum size-) to avoid your top-level window to collapse and become unusable, setting a maximum size... One common setting is making minimumSize = maximumSize
, so you make the window fixed size (you can use the convenience method setFixedSize
).
PS: see that this has nothing to do with the sizePolicy
, which simply indicates parent layout which actions can be taken -regarding size- when placing the widget. As a top-level window has no parent layout this policy is simply not used.
Upvotes: 1