[PyQt] layout management serious problem
apaku at gmx.de
Fri Oct 12 14:06:21 BST 2007
On 12.10.07 15:36:57, think_resist at hushmail.com wrote:
> uglier)! So I've realized i have to use a layout manager...I've
> read many texts in the web but i don't get the logic behind this
> thing. Can't i just create the mainwindow, the size i want, then
> create the central widget, create a layout manager, put the central
> widget on it and then start adding widgets on the central widget,
The other way around, you set a layout on your central widget and then
add widgets to the layout (or simply create them with the central widget
as parent). Then all the widgets will be layed out depending on the type
of layout you use. A QVBoxLayout will put all widgets in a vertical row,
QHBoxLayout in a horizontal row. With QGridLayout you can create a grid
of cells and when adding the widgets you can define how many cells it
Nesting layouts provide an easy way to create more complex setups and
also spacers help there.
BTW: Did you have a look at Qt designer? It allows you to lay out your
mainwindow in a graphical way and you won't have to worry about the
details how to use the various layouts. Its an easy way to try out what
happens if you change things.
> or this is no tgoing to work? Do I have to write down how each
> widget will grow or shrink?
No, thats exactly what you don't do with layouts.
Be free and open and breezy! Enjoy! Things won't get any better so
get used to it.
More information about the PyQt