How to get minimum size Mainframe?
-
Hi Forum,
I want a mainframe that can not get smaller than the collection of the minimum size widgets it contains.
Is there a general setting or way how to achieve this, instead of writing my own resize event for the mainframe? Or ist that the only way?
Could not find good info about this topic.
Recommendations for other methods or ideas are welcome. -
@SiGa
I always fight with Qt layouts/policies too, even after all this time! Have you tried QSizePolicy::Maximum? You still have to calculatesizeHint()
yourself dynamically to the bounding rectangle of the widget contents, I believe. Or there is setMaximumSize(). Whether this is any simpler than trappingresize
event I don't know. -
@JonB
Glad to hear that also experts struggle at some things , guess we are still human ;)I need to provide an example for better understanding.
I have my GUI program which has a default size, that I assume the user will be happy with.
Now the user changes the size of the mainframe(i.e. the topmost frame|widget) by dragging the corner with the mouse.
He can drag it so small, that elements in the mainframe start overlapping and it turns unusable.
I want to prevent dragging it to an unusable size. -
I'm not sure what you are doing. If the mainframe has a layout and all widget are inside nested layout, you cannot go below the minimum size of each individual widget and nothing will overlap. So, somehow you have used the layouts wrong. Without any code/.ui files it is really hard to diagnose the problem.
-