diff options
-rw-r--r-- | src/gui/widgets/qlinecontrol_p.h | 6 | ||||
-rw-r--r-- | src/gui/widgets/qlineedit.cpp | 2 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/gui/widgets/qlinecontrol_p.h b/src/gui/widgets/qlinecontrol_p.h index a81f138..f46abf1 100644 --- a/src/gui/widgets/qlinecontrol_p.h +++ b/src/gui/widgets/qlinecontrol_p.h @@ -109,6 +109,7 @@ public: int width() const; int height() const; int ascent() const; + qreal naturalTextWidth() const; void setSelection(int start, int length); @@ -410,6 +411,11 @@ inline int QLineControl::width() const return qRound(m_textLayout.lineAt(0).width()) + 1; } +inline qreal QLineControl::naturalTextWidth() const +{ + return m_textLayout.lineAt(0).naturalTextWidth(); +} + inline int QLineControl::height() const { return qRound(m_textLayout.lineAt(0).height()) + 1; diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index 3065c7f..9571860 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -1808,7 +1808,7 @@ void QLineEdit::paintEvent(QPaintEvent *) // (cix). int minLB = qMax(0, -fm.minLeftBearing()); int minRB = qMax(0, -fm.minRightBearing()); - int widthUsed = d->control->width() + minRB; + int widthUsed = qRound(d->control->naturalTextWidth()) + 1 + minRB; if ((minLB + widthUsed) <= lineRect.width()) { // text fits in lineRect; use hscroll for alignment switch (va & ~(Qt::AlignAbsolute|Qt::AlignVertical_Mask)) { |