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

Auto scale Widgets when i resize the Window



  • Hello,i got a problem on my Application
    Im making a code editor with QT and i wanna auto scale the widgets when i resize the window.
    I check google for a long time and tried horizontal layout,grid layout.... etc.
    But the result is not what i want,this is what my editor looks like:
    Screenshot 2020-12-29 133415.png

    and when i make it maximum,it become this:

    Screenshot 2020-12-29 133426.png

    i wanna make it auto scale,i tried grid layout and i dont like it is because it make a small grid between them.I want all of them stick together.

    and yea,if i use grid layout,the left list view and right code area will become same width.And i cant change it.

    Please help me,thank you


  • Lifetime Qt Champion

    Hi
    Did you try the layoutStretch
    alt text

    It tells how to share the space. normal its even shared but you can tell it to
    share so one widget get less than others etc.

    alt text

    When you set the stretching values, it will keep this layout even when you maximize.

    ps. i used horizontalLayout


  • Lifetime Qt Champion

    Hi,

    If you would like to be able to adjust both widgets you might want to consider using QSplitter.

    Otherwise you have to give more details about the structure of your GUI.



  • @SGaist Okay i will give more details about my UI
    Im making a code editor as the picture i sent above.
    And i used Grid Layout but then there will have Gap between all widgets,can i ask how do i remove the gap?
    I used right click the mainwidows and click layout and click grid layout.Please help me,thank you = D

    My english is sucks sorry


  • Lifetime Qt Champion

    Hi
    Did you try the layoutStretch
    alt text

    It tells how to share the space. normal its even shared but you can tell it to
    share so one widget get less than others etc.

    alt text

    When you set the stretching values, it will keep this layout even when you maximize.

    ps. i used horizontalLayout



  • @mrjj Alright,i found the way myself from you.Thank you for helping me,I made a layout of mainwindow,and i change the scretch by clicking centrelwidget button

    Thanks for your help


Log in to reply