QLineEdit: Include the horizontal margin in minimumSizeHint

The margin is respected in the sizeHint, but not in the minimumSizeHint.
Since the latter should be the former for a single character (as per the
documentation promising enough space for one character), the margin
calculation needs to be identical.

Adjusting the documentation nevertheless, as there are characters that
won't fit either way. As reported, the permyriad character doesn't fit
even with this fix on macOS, as the core graphics API we are using
doesn't report a glyph-index for U+2031 (so our existing assumption
that 'W' is the widest character is still the best we can do).

Change-Id: I30573960c316cc7b8c9bbe3c3f4c6351792bed36
Fixes: QTBUG-82970
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
bb10
Volker Hilsheimer 2020-03-25 18:06:31 +01:00
parent b3b51a7665
commit 5f87fb8813
1 changed files with 2 additions and 2 deletions

View File

@ -701,7 +701,7 @@ QSize QLineEdit::sizeHint() const
/*!
Returns a minimum size for the line edit.
The width returned is enough for at least one character.
The width returned is usually enough for at least one character.
*/
QSize QLineEdit::minimumSizeHint() const
@ -713,7 +713,7 @@ QSize QLineEdit::minimumSizeHint() const
int h = fm.height() + qMax(2 * QLineEditPrivate::verticalMargin, fm.leading())
+ tm.top() + tm.bottom()
+ d->topmargin + d->bottommargin;
int w = fm.maxWidth()
int w = fm.maxWidth() + 2 * QLineEditPrivate::horizontalMargin
+ tm.left() + tm.right()
+ d->leftmargin + d->rightmargin;
QStyleOptionFrame opt;