diff options
author | David Faure <david.faure@kdab.com> | 2014-09-25 17:23:15 +0200 |
---|---|---|
committer | Konstantin Ritt <ritt.ks@gmail.com> | 2014-11-27 04:19:05 +0100 |
commit | 2d0b20ef9218aa40218ab6c872a60c28e56b1ac2 (patch) | |
tree | bfed769d44ca06aa350a6e30de0335ce06105d53 /src/widgets/widgets | |
parent | b9d98c10bdc3c8e6330e84cca48ea302e8cd61c3 (diff) |
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 <giuseppe.dangelo@kdab.com>
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r-- | src/widgets/widgets/qlineedit.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index cf294e3c34..bd8dd783ff 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -712,8 +712,11 @@ QSize QLineEdit::minimumSizeHint() const ensurePolished(); QFontMetrics fm = fontMetrics(); int h = fm.height() + qMax(2*d->verticalMargin, fm.leading()) + + d->topTextMargin + d->bottomTextMargin + d->topmargin + d->bottommargin; - int w = fm.maxWidth() + d->leftmargin + d->rightmargin; + int w = fm.maxWidth() + + d->effectiveLeftTextMargin() + d->effectiveRightTextMargin() + + d->leftmargin + d->rightmargin; QStyleOptionFrame opt; initStyleOption(&opt); return (style()->sizeFromContents(QStyle::CT_LineEdit, &opt, QSize(w, h). |