Please nominate your Qt Champions for 2021!

Window size adjustment

  • Hi everybody,

    I'm having some troubles with the window size of my application. The first one is when i resize the window i want to keep the aspect ratio of some widgets inside. I try with different topics of this forum but finally i couldn't do it.

    The second problem is when i put more than 2 of these widgets i were speaking about, because the window comes bigger than the screen size. When this happens the maximize button disappear. For this i tried to play with the maximum size but this solution doesn't fit to the application features.

    Any suggestion will be very helpfull, thanks!

  • Moderators

    Can you post some code? That would help out a lot.

    It sounds like maybe you want control over sizing of widgets in general. One method I use if I don't want things sized is to add spacers on each side of the widget to the layout. This will keep it from sizing with the window.

    If you want certain aspect ratios though you would probably need to size each widget manually based on the new geometry of the window. So when the window gets resized you then manually size the widgets based on what ratio you want.

  • I tried what you told me with spacers but the problem is same. I don't want to select a maximum size because i use more than one screen and also i have dockable widgets to make them bigger if its needed.

    Thanks ambershark!

  • Moderators

    You don't need to select a maximum size. You can just get the size of the window after a geometry change and then use those values to calculate (based on your desired ratio) the size of the widgets, then resize them accordingly.

  • I solve it adjusting the sizepolicy to Expanding, now is not big anymore. What i have to find is how to keep the aspect ratio when the window is resized. I try some functions that i saw on this forum without success. Anyway i will try now again after fixing this extrasizing that i aforementioned.


Log in to reply