summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2020-03-25 18:06:31 +0100
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2020-03-26 14:56:57 +0100
commit5f87fb881383f6170ca2cf82958709b04372aae6 (patch)
treefc846069b89e228739b80ebfa664d73ad85c87fb /src
parentb3b51a7665dae78db352ccdeb5f25f0e5df43c09 (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/widgets/qlineedit.cpp4
1 files 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;