Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.14.0
-
None
-
-
5f87fb881383f6170ca2cf82958709b04372aae6 (qt/qtbase/5.15)
-
Q1/2020 Finale
Description
The documentation of QLineEdit::minimumSizeHint claims:
The width returned is enough for at least one character.
This is not actually the case, as can be seen in the attached screenshot for the character ‱.
The reason is that qlineedit_p.cpp has an additional 2 pixel magic margin (QLineEditPrivate::horizontalMargin) it adds, but the minimumSizeHint function forgets about using that.
We noticed this when trying to make a line edit have at least the width of its text, by querying its minimumSizeHint and subtracting the font metric's maximumCharWidth, then adding the width of the contained text. This should always work according to the documentation, but leaves the text cropped by 4 pixels ([left + right] * 2 pixels) in practice.