-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi guys, slowly slowly I am getting there, thanks to your assistance! There is one last thing that I need to address:
within my grid layout, I want to place some widgets on a different position, than the (row, column) system allows me. (for example place two buttons together, under the same (row,column) combination. Can I do this, or do I have to implement a different layout? On Sat, 13 Oct 2007 00:25:51 +0300 Andreas Pakulat <[EMAIL PROTECTED]> wrote: >On 12.10.07 23:31:28, [EMAIL PROTECTED] wrote: >> On Fri, 12 Oct 2007 16:05:51 +0300 Mark Summerfield ><[EMAIL PROTECTED]> >> wrote: >> >On 2007-10-12, [EMAIL PROTECTED] 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 >> >centralwidget >> >> and 15 widgets (textedit, linedit, pushbuttun) that belong to >> >the >> >> centralwidget. I've written their size, heigh , position and >> >> everythig worked so far. When I got the program to run on a >> >system >> >> 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 >> >central >> >> widget on it and then start adding widgets on the central >> >widget, >> >> 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 >> >help >> >> 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 >> button. > >If you set the pixmap with setPixmap then the QPushButton will >adjust >itself to the pixmap size. This is the reason for using layouts, >you >don't have to care about setting the sizes of your widgets. If >your >layout is properly done and your top-level-window is large enough >all >will enlarge themselves so they show all their content. Some will >even >grow automatically beyond their minimum-needed size (for example a >lineedit that has free space to its right). > >> >It is almost always a mistake to specify sizes for Qt widgets >> >(except >> >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 >> >appropriately >> > # ... >> > 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? > >Everything is possible :) If you want a QPushButton to expand >beyond its >needed size then tell it by setting its vertical size policy to >expanding. > >As far as "make it bigger from initialization", thats not needed >as I >said above. If you put an image into the button and the button has >enough free space (or the layout can shrink another widget) it >will >expand automatically. > >I'd suggest to fire up Qt designer and do a couple of tests on a >plain >QWidget to get a feel for how layouts work and maybe even design >your >GUI in designer instead of coding it up. That saves a lot of time >if you >ever need to re-arrange things or insert a new subwidget >somewhere. > >Andreas > >-- >Chicken Little was right. >_______________________________________________ >PyQt mailing list [email protected] >http://www.riverbankcomputing.com/mailman/listinfo/pyqt -----BEGIN PGP SIGNATURE----- Note: This signature can be verified at https://www.hushtools.com/verify Charset: UTF8 Version: Hush 2.5 wpwEAQECAAYFAkcSZ1YACgkQMthlogX/iJRqawP/SffxWoO2jIplfRQefXsxgx2tdvfl 15NHtLYG5YQRLVKRQ+AJwBUzXUSfpylO+BPq+SEkz6zYxQCRb/UNoatGzQwOAw37Gsw0 LqF8mZ57e7ADPf31YcyhYdbTaqoUCi5jjHcFEMZ681WnnHBqXZXJX2tMPaDmK4A23GC6 JEBz0N4= =agh/ -----END PGP SIGNATURE----- _______________________________________________ PyQt mailing list [email protected] http://www.riverbankcomputing.com/mailman/listinfo/pyqt
