I have a QWidget (window) with QHBoxLayout which contains two QPushButtons. If I make the window bigger (very wide) two things happen:
- The buttons grow to their maximum width
- The space between and around the buttons grows too.
But I need another behavior:
- The widget could grow and shrink as usual
- The space between and around the buttons should not grow (it must be constant).
- When the buttons reach their maximal width, the widget further grow must be restricted
How to reach the above behavior?
UPD:
I propose the following code:
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QWidget wgt;
QPushButton* button1 = new QPushButton("Button1");
QPushButton* button2 = new QPushButton("Button2");
button1->setMinimumSize(150, 100);
button1->setMaximumSize(250, 100);
button2->setMinimumSize(150, 100);
button2->setMaximumSize(250, 100);
QHBoxLayout* pLayout = new QHBoxLayout(&wgt);
pLayout->addWidget(button1);
pLayout->addWidget(button2);
wgt.setLayout(pLayout);
wgt.setGeometry(400, 400, 800, 300);
wgt.show();
return app.exec();
}
I need that layout should be restricted from min to max (cant be less than min and cant be larger than max) + without stretching the space (it must have fixed size) between and around the buttons.