From 2d0b20ef9218aa40218ab6c872a60c28e56b1ac2 Mon Sep 17 00:00:00 2001 From: David Faure Date: Thu, 25 Sep 2014 17:23:15 +0200 Subject: QLineEdit: take text margins into account in minimumSizeHint(). sizeHint() did it exactly like this, but minimumSizeHint() didn't, which made it too small. Didn't affect the actual size in most cases since the vertical size policy is fixed, so sizeHint() is called instead. But when writing a subclass, if one re-implements sizeHint() by calling the QLineEdit's minimumSizeHint(), it would then be wrong, when text margins are used. Change-Id: I29ae8dcab00842b3b5ca534cdb250efc0b496f45 Reviewed-by: Giuseppe D'Angelo --- tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests/auto/widgets/widgets') diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index 78fa0b4928..bf4d1f2ebd 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -3384,10 +3384,20 @@ void tst_QLineEdit::textMargin() testWidget.setCursorPosition(6); QSize sizeHint = testWidget.sizeHint(); + QSize minSizeHint = testWidget.minimumSizeHint(); testWidget.setTextMargins(left, top, right, bottom); + sizeHint.setWidth(sizeHint.width() + left + right); sizeHint.setHeight(sizeHint.height() + top +bottom); QCOMPARE(testWidget.sizeHint(), sizeHint); + + if (minSizeHint.width() > -1) { + minSizeHint.setWidth(minSizeHint.width() + left + right); + minSizeHint.setHeight(minSizeHint.height() + top + bottom); + QCOMPARE(testWidget.minimumSizeHint(), minSizeHint); + } + + testWidget.setFrame(false); centerOnScreen(&tlw); tlw.show(); -- cgit v1.2.3