<Solved>How can I resize child widgets after applying a layout on a parent widget ??



  • Hi all,

    I am facing a problem when i apply layouts in a widget. then size of child widgets are changed automatically. but now, I want to resize it again as same size as earlier to applying layout. but it is not allowing to do so.

    So, please tell me how can i resize child widgets after applying layout?

    Thanx in Advance.


  • Moderators

    @
    widget.setLayout(something);
    widget.resize(widget.sizeHint());
    @



  • Hi sierdzio,

    thank u for the help. but i want to do it in designer mode. once i set layout on widget in qt designer. then child widgets are locked. Therefore, i am unable to resize them. Is there any way to resize these child widgets ??


  • Moderators

    You need to resize the whole window, then. Child sizes are managed by the layout.

    You can experiment with size policy settings (change to Preffered, Minimal, Expanding, etc.).



  • Hi sierdzio, I have experimented with size policy settings. Yes, It applied some changes in my ui. but that is not as per my requirement since those changes are bound also.

    Any way, thanx for the suggestion . if there is any other way to perform this. then please share with me. Thank you.


  • Moderators

    You can also set the minimum- and maximumSize properties to force the layout to use certain sizes. But the whole point of layouts in widgets is not to care about subwidget sizes: that is the job for the layout.



  • Okah. means when we applied any layout then we don't have full control over widget's size properties. hence it is the job of layout . Am i right ??


  • Moderators

    Correct. Layouts are there to save you the hassle of manually setting x, y, width and height coordinates. They will fill the available space according to the rules of a particular layout (horizontal layout, grid, vertical, etc.).



  • Okah. Thank you. sierdzio.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.