summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-04-29 15:01:04 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-05-06 07:57:11 (GMT)
commit244f5ee9c2c34ddee200e4d5cdc1345762a5901b (patch)
tree12841f52f170972109281ea4115147ff0e063289 /tests/auto
parent548da9a5434d615456a7a6efda3380b7138c6000 (diff)
downloadQt-244f5ee9c2c34ddee200e4d5cdc1345762a5901b.zip
Qt-244f5ee9c2c34ddee200e4d5cdc1345762a5901b.tar.gz
Qt-244f5ee9c2c34ddee200e4d5cdc1345762a5901b.tar.bz2
Fix QFormLayout which allowed fields to be smaller that their minimum size
If the label's sizeHint is bigger than its minimumSizeHint, the field may be resized smaller than its minimum size. This also fix another problem where the field would 'jump' from one sizehint to the others. (This can happen if labels can word-wrap for example) Reviewed-by: Michael Goddard
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qformlayout/tst_qformlayout.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/auto/qformlayout/tst_qformlayout.cpp b/tests/auto/qformlayout/tst_qformlayout.cpp
index c4c6f70..242974d 100644
--- a/tests/auto/qformlayout/tst_qformlayout.cpp
+++ b/tests/auto/qformlayout/tst_qformlayout.cpp
@@ -125,6 +125,7 @@ private slots:
Qt::Orientations expandingDirections() const;
*/
+ void fieldMinimumSize();
};
tst_QFormLayout::tst_QFormLayout()
@@ -905,6 +906,35 @@ void tst_QFormLayout::layoutAlone()
QTest::qWait(500);
}
+
+void tst_QFormLayout::fieldMinimumSize()
+{
+ //check that the field with is bigger than its minimumSizeHint for any size of the widget
+ // even if the label with is not fixed
+ QWidget w;
+ QFormLayout layout;
+ layout.setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
+ w.setLayout(&layout);
+ QLabel label1("Here is a strange test case");
+ label1.setWordWrap(true);
+ QLabel label2("Here is another label");
+ label2.setWordWrap(true);
+ QLabel shortLabel("short");
+ QLabel longLabel("Quite long label");
+ layout.addRow(&label1, &shortLabel);
+ layout.addRow(&label2, &longLabel);
+ w.show();
+ int width = w.size().width() + 9;
+
+ do {
+ w.resize(width, w.size().height());
+ layout.activate();
+ QVERIFY(shortLabel.size().width() >= shortLabel.minimumSizeHint().width());
+ QVERIFY(longLabel.size().width() >= longLabel.minimumSizeHint().width());
+ width -= 3;
+ } while(width >= w.minimumSizeHint().width());
+}
+
QTEST_MAIN(tst_QFormLayout)
#include "tst_qformlayout.moc"