Nominate our 2022 Qt Champions!

[solved] How in QtDesigner can I change the min or max size of a widget?

  • Why doesn't the QtDesigner allow me to set sizes of widgets to a value I enter?

    For example, I have two QTextEdit widgets in an QVBoxLayout.
    If I right click on the first QTextEdit widget and select "Size Constraints | Set Minimum Width", I'm not prompted to enter a value. The designer takes the current size and uses it. This size, however, isn't the size I want to use for the minimum widgth.

    The current solution, is to add code at runtime like:


    Is there a way in QtDesigner to set this property?

    I'm new to Qt and there might be a way that I'm not aware of. Also, if this has already been asked and answered, please just point me to that link, and sorry for re-posting.

  • Moderators

    On the right side of the designer there's a property editor (the yellowish table). In it all the properties of currently selected object are listed. What you're looking for are the properties named minimumSize and maximumSize. Expand them to set min/max width/height.

    Notice that the right click method you found just sets these to the current value. It's a convenience feature.

  • Thanks for the answer! It worked as you described. And just as I wanted so no code is needed and I can use QtEditor only.

    I never (until now) tried to double-click on the property name. I did try to double-click on the property value (in an attempt to open up an popup editor for the field) but nothing happened so I didn't know this was possible.

    Thanks for letting me know how to do this.

Log in to reply