Solved QGridLayout - I don't get it :(
-
Hi all and thanks for reading.
I put a QGridLayout into a QWizardPage but it does not look as expected. In the third line, which should display a field for postal code and city - the postal code field is bigger than that of the city. Despite this code:QGridLayout* grid = new QGridLayout; grid->addWidget(leAddress1, 0, 0, 1, 5); grid->addWidget(leAddress2, 1, 0, 1, 5); grid->addWidget(leStrasse, 2, 0, 1, 5); grid->addWidget(lePlz, 3, 0, 1, 1); grid->addWidget(leStadt, 3, 1, 1, 4); grid->addWidget(leEmail, 4, 0, 1, 5); grid->addWidget(leUrl, 5, 0, 1, 5); setLayout(grid);
-
OK - I found a solution! This code does the trick:
QGridLayout* grid = new QGridLayout; grid->addWidget(leAddress1, 0, 0, 1, 5); grid->addWidget(leAddress2, 1, 0, 1, 5); grid->addWidget(leStrasse, 2, 0, 1, 5); grid->addWidget(lePlz, 3, 0); grid->addWidget(leStadt, 3, 1, 1, 4); grid->addWidget(leEmail, 4, 0, 1, 5); grid->addWidget(leUrl, 5, 0, 1, 5); grid->setColumnStretch(0, 1); grid->setColumnStretch(1, 4);
https://photos.app.goo.gl/xPWJtbQ2s9XAtZuZ9
So the position in the grid plays less of a role - it is more about the stretching... Not that I think that I totally understand - but... it works.
Thx if you thought about helping.Regards
HM -
OK - I found a solution! This code does the trick:
QGridLayout* grid = new QGridLayout; grid->addWidget(leAddress1, 0, 0, 1, 5); grid->addWidget(leAddress2, 1, 0, 1, 5); grid->addWidget(leStrasse, 2, 0, 1, 5); grid->addWidget(lePlz, 3, 0); grid->addWidget(leStadt, 3, 1, 1, 4); grid->addWidget(leEmail, 4, 0, 1, 5); grid->addWidget(leUrl, 5, 0, 1, 5); grid->setColumnStretch(0, 1); grid->setColumnStretch(1, 4);
https://photos.app.goo.gl/xPWJtbQ2s9XAtZuZ9
So the position in the grid plays less of a role - it is more about the stretching... Not that I think that I totally understand - but... it works.
Thx if you thought about helping.Regards
HM -
understanding size policies are also important, but admittedly, they are a PITA to get right.