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

Can't change size of widgets inside layouts in QDesigner



  • Hi,

    I have created two tab-widgets and inside the left one I created three QTreeWidgets.
    I created layouts with vertical splitter to split tab-widgets and layout with horizontal splitters to split QTreeWidgets.
    Now I need to set size for tab-widgets: left tab should have width lesser than width of right tab.
    As you can see on the pictures I can't manipulate with their size and moreover when I launch the app the size dramatically changes :)
    How to set width of left tab as small as possible to the full text in QTreeWidgets and width of right side as big as possible?
    design.png app.png



  • Their dimensions are governed by sizePolicy and minimumSize and maximumSize attributes.



  • Their dimensions are governed by sizePolicy and minimumSize and maximumSize attributes.



  • @Kent-Dorfman Thank you!
    That helped. I changed numbers in size-policy (horizontal stretch) and I got something that I wanted even I still dont understand the affect of these numbers on the size of widgets. I.e I can set horizontal stretch equal to 1 or equal to 255 and the effect would be the same


  • Lifetime Qt Champion

    Hi,

    For the stretch value, if you have two widgets in a horizontal layout and both have a stretch of same value they will both take the same amount of space in the layout. If you put one stretch value at 1 and the other at 2, then the second widget will take more space than the first one based on the values used.



  • @SGaist thank you but still I have two widgets in horizontal layout. Both of them have Expanding size Policy. Here are some values of stretch and the result:

    • left widget stretch = 0, right widget stretch = 100 => right takes more space
    • left widget stretch = 1, right widget stretch = 100 => left takes more space
    • left widget stretch = 200, right widget stretch = 100 => left takes more space

    Actually the result from points 2 and 3 are equal i.e. there are only two positions of widgets for any variants of stretch. I'm talking about two widgets that are present in the picture above (tab widgets and left one includes three qtreewidgets)


Log in to reply