I have a dialog set up like this:
Every components' properties are set to their defaults aside from the captions. I want the row containing label_3
to be the same height as the other three rows (and that bottom row to be expanded to take up the remaining space, as shown, to be clear). The problem is the checkbox isn't the same height as the text boxes, so the row has a different height. According to Designer, in the image above label_1
and friends have height 20, and label_3
has height 13. None of the following attempts worked quite right:
- Messing with the
layoutRowStretch
property of theQGridLayout
has no effect. - I don't want to set a hard-coded fixed height because this may be run on other platforms or with other themes, and so I want to defer component sizes to system defaults.
Setting the height to match one of the other label heights in the constructor, e.g.:
ui->label_3->setFixedHeight(ui->label_2->height());
Yields incorrect results:
Debugging shows that
label_2->height()
in the constructor is 30, not 20 as reported in designer, and solabel_3
's row ends up too large. Presumably this is because the dialog hasn't been displayed yet at that point and so the components have not been laid out.
I'm out of ideas. What's the cleanest way to do this that also does not involve hard coding sizes?
A Qt5 project for the example above is here.