From 5f87fb881383f6170ca2cf82958709b04372aae6 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 25 Mar 2020 18:06:31 +0100 Subject: [PATCH] QLineEdit: Include the horizontal margin in minimumSizeHint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ø --- src/widgets/widgets/qlineedit.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index 06b40f9644..c578710f99 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -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;