How to reduce the distance between components in Qt layout?
-
In a Widget with a vertical layout, I have a QLabel and a QGridLayout. In the layout properties of this Widget, the layoutSpacing is set to only 5. However, in both the preview and actual program execution, there is a significant gap between the QLabel and the QGridLayout. Furthermore, when I continue to stretch the window vertically, this gap keeps increasing (the vertical policy of widgets in QGridLayout is set to preferred). I want the distance between the sub-layouts to remain fixed and very small while stretching the window. How can I solve this problem?
This is the layout property of the largest widget.
-
@IPlayGenji6 Set
0,1
to layout stretch property for giving all the space to the second item of your widget's layout. -
@IPlayGenji6
If you want the widgets to stay on top, add a spacer to the vertical layout. -
@IPlayGenji6 Then please show how you added a spacer.
-
@IPlayGenji6 Already fixed, I didn't find that there was a widget in the QGridLayout with the vertical policy set to fixed
-
I IPlayGenji6 has marked this topic as solved on