PDA

View Full Version : Qt Designer Different positions of text fields with same layout



Computer Hater
10th July 2011, 21:16
I suppose this qualifies as regarding Qt Designer, althought it's maybe a general programming issue.

I have 5 lines where the user is supposed to select up to 5 different files (see screenshots). The structure is all the same except that the last two files have an additional check box associated with them (currently textless).
I would like the 5 file names to appear exactly beneath each other in the same column, regardless of whether they have a check box or not.
To achieve that, I've placed the 5 groups in 5 horizontal layouts, put horizontal spacers in place of the check box for the first 3 groups and set the stretch factors of the elements to the exact same values for all 5 layouts (2,5,25,4,4 in this case).

Still, the file text in the groups with check boxes is not in line with the others but offset to the right.
The check boxes are not at their minimum size, so they could shrink to give the desired behaviour. If I decrease their stretch factor, I get the same effect in the other direction, i.e. an offset to the left side.

I noticed that there is also a visual offset already in design mode, albeit apparently less pronounced (at least to my eye).

Have I missed something about layout logic ?
What can I do ?
Thank you !

mvuori
10th July 2011, 21:25
If it turns out to not be possible, there is always the possibility of adding an extra column for just the checkboxes with no label.

Computer Hater
10th July 2011, 21:41
If it turns out to not be possible, there is always the possibility of adding an extra column for just the checkboxes with no label.

I'm not quite sure what you mean.
You mean build all layouts first without the check box element and then add the check boxes to some, or build all layouts and use empty columns where I now have spacer items ?
And how would I do that ? I'm building the form in Designer and there doesn't appear to be the option to add empty columns. So I guess I would need to add it in the code ?
Are you referring to QLayout's addItem method ? What would I be adding then ? Wouldn't I end up adding a spacer item anyway ?

Sorry for the plethora of questions. Thanks for the fast answer though. :b