Layout alignment across widgets
-
I am dealing with a form that contains a stacked widget. This allows the form to change its contents based on the selection made in a combo box. This is the form I'm talking about: http://imagebin.org/140899 , .ui source can be found here: http://pastebin.com/Xf1rXJe5
The part stacked widget has been highlighted with a blue box. What I'd like to achieve, is to create a nice alignment between all the widgets on the form, no matter if they are part of the stacked widget or not. I'd even like to be able to make sure the alignment between the different pages stays the same. For instance, I'd like all the widgets on the form to align to the green line I drew on the image above.
I am sure others have come across this problem before, or have dealt with similar problems like aligning widgets inside of different group boxes that are above another on the same form.
I find that scenario's like these, which I imagine to be quite common, is a weakness of Qt's layout system. What tricks do others use to work around this, and provide nicely aligned widgets even across different parent widgets?
-
http://imagebin.org/140899 give me 404 not found
-
I ran into this blog post recently:
http://agateau.wordpress.com/2011/01/28/clean-up-your-layouts-with-columnresizer/Might be a KDE-based solution, I have not yet checked it out.
-
[quote author="Marco Bavagnoli" date="1299155208"]ouch didnt seen :)
IMHO the solution is to set a minimun size to all the labels on the left, for example to 98 like the upper "Database type:"[/quote]
I'd rather not use fixed magic numbers. What would happen in a translated version of my application, for instance? In that case, the minimum label width might be completely different.
[quote author="Tobias Hunger" date="1299156197"]I ran into this blog post recently:
http://agateau.wordpress.com/2011/01/28/clean-up-your-layouts-with-columnresizer/Might be a KDE-based solution, I have not yet checked it out.
[/quote]This looks like what I need, thanks a lot!
Edit: indeed, this works quite nicely. It is not as slick as having this integrated in Qt proper, but it works nicely nonetheless.
-
[quote author="Tobias Hunger" date="1299156197"]I ran into this blog post recently:
http://agateau.wordpress.com/2011/01/28/clean-up-your-layouts-with-columnresizer/Might be a KDE-based solution, I have not yet checked it out.
[/quote]This link was really useful for me.
Thanks for this link posting. -
To show off the result of the corrected form using the ColumnResizer class from the blogposting Tobias pointed to:
Everything nicely aligned, even between the different pages from the widget stack that appear when you change the database type from the combo box.