[PyQt] layout management serious problem

think_resist at hushmail.com think_resist at hushmail.com
Fri Oct 12 21:31:28 BST 2007

Hash: SHA1

On Fri, 12 Oct 2007 16:05:51 +0300 Mark Summerfield <mark at qtrac.eu>
>On 2007-10-12, think_resist at hushmail.com wrote:
>> Hi all,
>> I'm completely confused on a simple thing (from what I read):
>> layout management
>> I've written a pyqt hui app that has a Mainwindow, a
>> and 15 widgets (textedit, linedit, pushbuttun) that belong to
>> centralwidget. I've written their size, heigh , position and
>> everythig worked so far. When I got the program to run on a
>> with different resolution, it was...10 times bigger (and 1000
>> 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
>> widget on it and then start adding widgets on the central
>> or this is no tgoing to work? Do I have to write down how each
>> widget will grow or shrink? Very confused, will appreciate any
>> very much
In this case I guess it is not, since my widgets have to be a
specific size, definitely not the default ones! Example,
QPushbuttons will show some images, so they can't be the size of a

>It is almost always a mistake to specify sizes for Qt widgets
>for top-level windows).
>Try something like this in your QMainWindow subclass's __init__():
>    # create the 15 widgets (no sizes, no positions!)
>    grid = QGridLayout() # Or any other layout
>    grid.addWidget(myWidget01, row, col) # set row, col
>    # ...
>    grid.addWidget(myWidget15, row, col)
>    centralWidget = QWidget()
>    centralWidget.setLayout(grid)
>    self.setCentralWidget(centralWidget)

in the case of a qpushbutton, this makes the button shrink or grow
only horizontally ! I need to get this grow/shrink vertically as
well, plus make it bigger from the initialization (that is specify
it's size). Is this possible with grid layout?


>Hope this helps!
>Mark Summerfield, Qtrac Ltd., www.qtrac.eu
Note: This signature can be verified at https://www.hushtools.com/verify
Charset: UTF8
Version: Hush 2.5


More information about the PyQt mailing list