PDA

View Full Version : How to resize a Button



Walsi
26th April 2007, 09:55
How to resize a QPushButton which is inside of a Layout?

the command


button->setGeometry(p1,p3,w,h);

has no effect!

Best Regards?

jpn
26th April 2007, 10:05
You are not supposed to resize widgets managed by a layout by hand. It's the layout's responsibility to provide sufficient geometries. There are numerous ways to adjust the behavior. Size hints, size policies, stretch factors and spacers, spacings, margins, nested layouts etc. I'd suggest starting with reading about layout classes (http://doc.trolltech.com/4.2/layout.html) and going through the basic examples.

If in doubt, provide a screenshot of what you've got so far and explain how would you like it to be and we might be able to give hints.

wysota
26th April 2007, 12:21
If you still really need to resize the button, use QWidget::setFixedSize() just be warned that you shouldn't do that if you don't have to. A better (but still not the best) approach is to use QWidget::setMinimumSize() and QWidget::setMaximumSize() to allow some flexibility.

MarkoSan
2nd April 2008, 01:08
Ok, I got that, but I have dynically located buttons in QGridLayout, which is taking too much place in my app. How do I resize it? Shold I resize every pushbutton added to QGridLayout or resize QGridLayout itself?