is there anybody to explain of sizepolicy?
-
i worte some test code to understand different of sizepolicy.
QHBoxLayout *layout = new QHBoxLayout(); layout->setContentsMargins(0,0,0,0); QPushButton *button1 = new QPushButton("minimun", this); button1->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); QPushButton *button2 = new QPushButton("preferred", this); button2->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); QPushButton *button3 = new QPushButton("maximum", this); button3->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed); layout->addWidget(button1); layout->addWidget(button2); layout->addWidget(button3); this->setLayout(layout);
i know difference of maximum and minimum,
but i don't understand difference of minimum and preferred,
because the stretching behavior of minimum is as same as it of preferred.i did read manpage serveral time, but i can't understand.
is there anybody to explain of sizepolicy?
thank you.
-
Hi, and welcome to the Qt Dev Net!
- Minimum: The widget is not allowed to be smaller than its sizeHint().
- Preferred: The widget is allowed to be smaller than its sizeHint().
This is described at http://doc.qt.io/qt-5/qsizepolicy.html#Policy-enum