Congratulations to our 2022 Qt Champions!

application window size control

  • How do I prevent the application window from getting resized by its layouts/widgets but allow it to be resized by the user using mouse or the maximize button?


  • Hello @applefier ,

    To fix the size of your layout you can use

    the setSizeConstraint ( SizeConstraint ) function

    and you have to put QLayout::SetFixedSize as arg of SizeConstraint

    Here is the doc explanation:

    sizeConstraint : SizeConstraint

    This property holds the resize mode of the layout.

    enum QLayout::SizeConstraint

    The possible values are:

    Constant	Value	Description
    QLayout::SetDefaultConstraint	0	The main widget's minimum size is set to minimumSize(), unless the widget already has a minimum size.
    QLayout::SetFixedSize	3	The main widget's size is set to sizeHint(); it cannot be resized at all.
    QLayout::SetMinimumSize	2	The main widget's minimum size is set to minimumSize(); it cannot be smaller.
    QLayout::SetMaximumSize	4	The main widget's maximum size is set to maximumSize(); it cannot be larger.
    QLayout::SetMinAndMaxSize	5	The main widget's minimum size is set to minimumSize() and its maximum size is set to maximumSize().
    QLayout::SetNoConstraint	1	The widget is not constrained.

    Hope this will work,

    Regards !

Log in to reply