How to resize a QPushButton which is inside of a Layout?
the command
has no effect!Code:
button->setGeometry(p1,p3,w,h);
Best Regards?
Printable View
How to resize a QPushButton which is inside of a Layout?
the command
has no effect!Code:
button->setGeometry(p1,p3,w,h);
Best Regards?
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 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.
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.
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?