If I have a QGridLayout and stack two widgets on top of each other, then they take up 50% of the layout each. However, if one of the widgets is a QLineEdit widget, then that widget takes up a much smaller portion of the layout than 50%.
How do I add two widgets to a QGridLayout, then set the initial portions to something other than 50%/50%?
The default vertical size policy of QLineEditis QSizePolicy.Fixed. That means it will always have the same height and other widgets might take available space in the layout.
So you might have to adjust the size policies of your widgets as Fenisko already demonstrated.
However if you have two or more expanding widgets in your layout, all will have equal size.
You can use QGridLayout.setRowStretch(int column, int stretch) and
QGridLayout.setColumnStretch(int column, int stretch) of your layout to adjust proportions of rows and columns.
Alterantively use QSizePolicy.setVerticalStretch(int stretch) and QSizePolicy.setHorizontalStretch(int stretch) of your widget's size policies.
What's the proper way to resize widgets in a layout?