diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index d95c004c8c..13e3a070b9 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -2031,6 +2031,7 @@ void QLineEdit::paintEvent(QPaintEvent *) } // the y offset is there to keep the baseline constant in case we have script changes in the text. + // Needs to be kept in sync with QLineEditPrivate::adjustedControlRect QPoint topLeft = lineRect.topLeft() - QPoint(d->hscroll, d->control->ascent() - fm.ascent()); // draw text, selections and cursors diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp index 6424c1452c..05b14b1007 100644 --- a/src/widgets/widgets/qlineedit_p.cpp +++ b/src/widgets/widgets/qlineedit_p.cpp @@ -70,12 +70,13 @@ QT_BEGIN_NAMESPACE const int QLineEditPrivate::verticalMargin(1); const int QLineEditPrivate::horizontalMargin(2); +// Needs to be kept in sync with QLineEdit::paintEvent QRect QLineEditPrivate::adjustedControlRect(const QRect &rect) const { QRect widgetRect = !rect.isEmpty() ? rect : q_func()->rect(); QRect cr = adjustedContentsRect(); int cix = cr.x() - hscroll + horizontalMargin; - return widgetRect.translated(QPoint(cix, vscroll)); + return widgetRect.translated(QPoint(cix, vscroll - control->ascent() + q_func()->fontMetrics().ascent())); } int QLineEditPrivate::xToPos(int x, QTextLine::CursorPosition betweenOrOn) const