Reputation: 399
I use QGridLayout and define layout as ui file.
I need to implement such layout:
|Column 0 |Column 1 |Column 2 |Column 3 |
|width enough to fit text|empty space|Line edit with width 66-70|width enough to fit text|
My problem are columns 1 and 2.
Which size policy should I use to give all the free space to column 1?
I am trying to set min width=66 and max width=70 to Column 2. And "Expanding" width policy to Column 1.
But for some reason, in this case column 1 is expanded more shat it should be and Column 2 has less than 66.
If I set size policy for column 1 as "maximum", than all the space is given to column 2. And width of that column is bigger than line edit widget, so it is not right aligned any more.
Upvotes: 0
Views: 504
Reputation: 98425
You're doing everything right except for the units.
I presume that your line edit's width is given in characters, but it seems like you're using that number to set the widths given in pixels.
I would set it the following way:
qreal em = QFontMetricsF(ui.lineEdit->font()).width('m');
ui.lineEdit->setMinimumWidth(round(em*66));
ui.lineEdit->setMaximumWidth(round(em*70));
Upvotes: 1