summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/kernel/qboxlayout.cpp6
-rw-r--r--tests/auto/qboxlayout/tst_qboxlayout.cpp27
2 files changed, 31 insertions, 2 deletions
diff --git a/src/gui/kernel/qboxlayout.cpp b/src/gui/kernel/qboxlayout.cpp
index d965933..fd16861 100644
--- a/src/gui/kernel/qboxlayout.cpp
+++ b/src/gui/kernel/qboxlayout.cpp
@@ -830,9 +830,11 @@ void QBoxLayout::setGeometry(const QRect &r)
if (d->hasHfw && !horz(d->dir)) {
for (int i = 0; i < n; i++) {
QBoxLayoutItem *box = d->list.at(i);
- if (box->item->hasHeightForWidth())
+ if (box->item->hasHeightForWidth()) {
+ int width = qBound(box->item->minimumSize().width(), s.width(), box->item->maximumSize().width());
a[i].sizeHint = a[i].minimumSize =
- box->item->heightForWidth(s.width());
+ box->item->heightForWidth(width);
+ }
}
}
diff --git a/tests/auto/qboxlayout/tst_qboxlayout.cpp b/tests/auto/qboxlayout/tst_qboxlayout.cpp
index 8887288..48235e8 100644
--- a/tests/auto/qboxlayout/tst_qboxlayout.cpp
+++ b/tests/auto/qboxlayout/tst_qboxlayout.cpp
@@ -66,6 +66,8 @@ private slots:
void sizeConstraints();
void setGeometry();
void setStyleShouldChangeSpacing();
+
+ void taskQTBUG_7103_minMaxWidthNotRespected();
};
class CustomLayoutStyle : public QWindowsStyle
@@ -246,6 +248,31 @@ void tst_QBoxLayout::setStyleShouldChangeSpacing()
delete style2;
}
+void tst_QBoxLayout::taskQTBUG_7103_minMaxWidthNotRespected()
+{
+ QLabel *label = new QLabel("Qt uses standard C++, but makes extensive use of the C pre-processor to enrich the language. Qt can also be used in several other programming languages via language bindings. It runs on all major platforms, and has extensive internationalization support. Non-GUI features include SQL database access, XML parsing, thread management, network support and a unified cross-platform API for file handling.");
+ label->setWordWrap(true);
+ label->setFixedWidth(200);
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(label);
+ layout->addSpacerItem(new QSpacerItem(1, 1, QSizePolicy::Fixed, QSizePolicy::Expanding));
+
+ QWidget widget;
+ widget.setLayout(layout);
+ widget.show();
+ QTest::qWaitForWindowShown(&widget);
+
+ int height = label->height();
+
+ QRect g = widget.geometry();
+ g.setWidth(600);
+ widget.setGeometry(g);
+
+ QTest::qWait(50);
+
+ QCOMPARE(label->height(), height);
+}
QTEST_MAIN(tst_QBoxLayout)
#include "tst_qboxlayout.moc"