Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Resize widgets when i resize the window



  • i have this :https://www.dropbox.com/s/1s6tm173kwy6l2g/screeshot.png
    I have 3 QTableView widgets, 2 scrollbars, one button and one line edit. How can i configure it so when i resize the window the widgets resize also?
    I have done a search and i as far as i undestand i have to add a layout. The problem is when i add a layout all the dimension of my widgets change and i can't change them back. What should i do?



  • Hi!
    Layouts are right design. Can you show code how you add layouts?



  • I think i don't quite undestand what do you mean. I don't write code for the layouts. I open my .ui file with the design and i try to add a layout by right click the top widget (in the box where it has object-layout) and then i press Lay Out and i choose one the listed options. (I use Qt5)



  • Ok. Did you set layout for main window?

    !http://s23.postimg.org/5x31pddmz/layout.png(layout)!



  • yes but i don't want the currrent widgets to be rearranged or the dimensions of the widgets change. Any of these option ruins the dimensions i have configure



  • I am sorry but i cant understand your goals.
    you want "when i resize the window the widgets resize also" but you don't want "dimensions of the widgets change" . And what you mean by "rearranged" ? When you put them in to layout you set the arrange.



  • I don't want the dimension to change when i add the layout. For example when i add the grid layout i get this :https://www.dropbox.com/s/01r9o9cv21phta5/screenshot2.png

    Of course when i resize the window i want the widgets to resize, that's why i want to add the layout to the widgets.

    Sorry if i am not explaining my problem, i am doing my best



  • In this case try play with sizePolicy of widgets. For example set sizePolicy->Vertical Policy = Expanding for left-bottom tableView and sizePolicy->Vertical Policy and Horizontal Policy = Expanding for rigth-bottom tableView.



  • ok i'll try this. Thanks



  • You can set the minimum dimensions of the widgets individually and then change the size policy. If these widgets have a layout associated with them, the on re-sizing the layout the widgets should automatically re-size. You can preview in the Qt-Designer and see if the functionality works as required by you.


Log in to reply