[Qt-interest] Help getting out of Gridlayout Hell
Scott Aron Bloom
Scott.Bloom at sabgroup.com
Sun Apr 26 22:41:01 CEST 2009
If I have group box A with sub layout of type vertical, and a group box
B with a sub layout of type vertical.
Setting each of their margins to the same value, will have both sets of
group boxes vertically laid out widgets line up.
In code:
QWidget * widget = new QWidget;
QVBoxLayout * mainVb = new QVBoxLayout( widget );
QGroupBox * gb = new QGroupBox;
mainVb >addWidget( gb );
QVBoxLayout * vb = new QVBoxLayout( gb );
vb->addWidget(new QLabel( "label1" ) );
vb->addWidget(new QLabel( "label2" ) );
vb->addWidget(new QLabel( "label3" ) );
gb = new QGroupBox;
mainVb >addWidget( gb );
vb = new QVBoxLayout( gb );
vb->addWidget(new QLabel( "label4" ) );
vb->addWidget(new QLabel( "label5" ) );
vb->addWidget(new QLabel( "label6" ) );
widget->show();
now.. if I add a third widget, that item WILL certainly NOT line up with
the sub lablels...
mainVb->addWidget( new QLabel( "label7" ) )
And in my view it shouldn't, since you grouped the subs anyway
Scott
> -----Original Message-----
> From: qt-interest-bounces at trolltech.com [mailto:qt-interest-
> bounces at trolltech.com] On Behalf Of Jake Colman
> Sent: Sunday, April 26, 2009 1:33 PM
> To: qt-interest at trolltech.com
> Subject: Re: [Qt-interest] Help getting out of Gridlayout Hell
>
>
> I'll try it but think of this another way. How can you create two
> independent group boxes that have exactly the same alignment?
Remember
> that a groupbox uses an internal gridlayout. The size of each cell in
> the grid depends on the cell's contents. Two independent groupboxes
> with independent gridlayout may end up with different sizing. How do
> you make it consistent?
>
>
> >>>>> "SAB" == Scott Aron Bloom <Scott.Bloom at sabgroup.com> writes:
>
> SAB> Setting the margins to 0 might help.
>
> >> -----Original Message-----
> >> From: qt-interest-bounces at trolltech.com [mailto:qt-interest-
> >> bounces at trolltech.com] On Behalf Of Jake Colman
> >> Sent: Saturday, April 25, 2009 7:23 PM
> >> To: qt-interest at trolltech.com
> >> Subject: [Qt-interest] Help getting out of Gridlayout Hell
> >>
> >>
> >> I have a number of widgets that need to be laid out in a grid.
This
> SAB> is
> >> normally nice and simple. The problem is that I need to use a
> SAB> groupbox
> >> to group some of the widgets in this grid. The problem is that
the
> >> widgets in the grid do not align with the widgets in the
groupbox.
> SAB> How
> >> do I get around this?
> >>
> >> This is with Qt 3.3 but I don't think layout management changed
much
> >> between 3.x and 4.x.
> >>
> >> Thanks for your help.
> >>
> >> ...Jake
> >>
> >>
> >> --
> >> Jake Colman | Director, Software Development
> >> Principia Partners LLC
> >> 101 West Elm Street | Conshohocken | PA 19428 | +1 (610) 755
9770
> >> t: +1 (610) 755 9786 | c: +1 (610) 348 2788 | f: +1 (201) 221
8929
> >> e: colman at ppllc.com | w: www.principiapartners.com
> >> Credit technology innovation awards winner 2008
> >>
> >> _______________________________________________
> >> Qt-interest mailing list
> >> Qt-interest at trolltech.com
> >> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
> --
> Jake Colman | Director, Software Development
> Principia Partners LLC
> 101 West Elm Street | Conshohocken | PA 19428 | +1 (610) 755 9770
> t: +1 (610) 755 9786 | c: +1 (610) 348 2788 | f: +1 (201) 221 8929
> e: colman at ppllc.com | w: www.principiapartners.com
> Credit technology innovation awards winner 2008
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list