[PyKDE] Re: Inserting widgets "into" a QGroupBox (David Boddie)

David Boddie david at boddie.org.uk
Fri Feb 2 22:33:23 GMT 2007


On Friday 02 February 2007 22:34, Tony Cappellini wrote:

> > Now comes the tricky bit. You need to apply a grid layout to the
> > widgets in
>
> When you say 'widgets'- do you mean all of the group boxes as well (except
> for the outer-most group box)- in the left layout, or just the widgets
> inside of the group boxes?

All of the group boxes in the left layout, not the contents of the inner
group boxes (the text edits, radio buttons, etc.)

> Do I apply the grid layout to the spacers as well?

Yes. If you click in the left outermost group box, you should just be able
to apply a grid layout by either clicking on the toolbar button with the
grid on it, or by opening the context menu on the form and selecting the
relevant option in the "Layout" submenu.

> After I applied the grid box, a red box appeared around the outline of the
> grid layout, and squished everything vertically.

OK. You're applying layouts that way! :-)

I was applying a layout when there was only one widget selected. The effect
of applying a layout that way is to apply it to that single widget's
children.

> I've selected the 3 inner group boxes, but the APply Layout buttons are
> disabled.

This usually means that there's already a layout - or something like that.
Sometimes it's not really all that intuitive to use. :-(

> > Generally speaking, I think many people come to Qt's layout system from
> > systems where you place and resize widgets to have fixed geometries,
> > and they're upset that you can't do this once you apply layouts to
> > widgets.
>
> upset- not, but lost yes. Looking at the docs, there's one paragraph about
> the layouts I'd say knowing how to apply the layouts & spacers are 80% of
> using Designer.

I think you're right! Of course, the people writing the manuals have had a
fair amount of experience using Designer, and they know lots of tricks to
get things looking right.

> I had originally dragged the layouts onto the from, instead of applying
> them.
> Not sure what the differences are, but my way obviously didn't work.

Unlike Python, Qt Designer has more than one obvious way to do lots of
things. ;-)

[Using slides as a tutorial]

> > I think it could be improved and made less like a presentation. Some of
> > the earlier slides could be removed, for example.
>
> Visual information is good.
> Also- before after, like when selecting widgets, then applying the layouts.

Yes, I would have done that for the brief walkthrough in my last message
except that I couldn't think of an obvious place to put the pictures. :-)

Incidentally, have you seen this (admittedly old) presentation about Designer?

  http://www.trolltech.com/products/qt/learnmore/video/demos/browser

> > OK. This kind of reinforces my impressions about "learning layouts". As I
> > said above, I think people sometimes have preconceptions about how to
>
> Sure- I came in with expectations that applied to a previous WYSIWIG, which
> isn't the way to go.

Still, it needn't be so hard to use. Most things I do with Designer are quite
simple, so it shocked me a little to see how hard it was to do what you
wanted.

> > create user interfaces that aren't quite applicable when using layouts,
> > or there's some confusion about what layouts actually are.
>
> I Agree

I think there are conflicting sources of information that can cause
confusion. A reasonable source of information can be found in the Qt
documentation:

  http://doc.trolltech.com/4.2/layout.html

Having said that, the above document does get into advanced issues rather
quickly. Maybe it's time to start writing another tutorial. :-/

David




More information about the PyQt mailing list