to set the widget to a fixed size in the code that you call setFixedSize (int h, int w) in the widgets. To do this in Designer, click on the widget and look in the property editor in the QWidget section. open the sizePolicy thingy and set the horizontal and / or vertical value to fixed. Then open the Geometry and set the width and height.
To make them stretched with different coefficients in the code, you use a separate argument when using the window layout. e.g. layout-> addWidget (button1, 1); layout-> addWidget (button2, 2); this will cause button 2 to expand at twice the speed of button1. To do this in the designer, open the widgets sizePolicy property and set HorizontalStrech and / or VerticalSretch. Please note that in this case, the size policy should not be fixed in the direction in which you want to configure stretching. In addition, it will never allow a widget to be smaller than its minimum size (this would ruin the ratio rather than reduce something too small).
source share