Report ImAbsolutePosition for QLineEdit

ImAbsolutePosition was added in f8dbed12266c42785c1e4758eed05833ec035f33,
based on requirements on Android, but without an implementation for
QLineEdit. It would seem sensible to fall back to the cursor position
in this case, as QLineEdit doesn't support multiple blocks.

Pick-to: 6.2
Change-Id: Iff1255270ceef069f03ce457df633d7b675f1a28
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Tor Arne Vestbø 2021-08-18 13:40:42 +02:00
parent 7188e65077
commit 61d4f7e228
2 changed files with 6 additions and 0 deletions

View File

@ -1855,6 +1855,7 @@ QVariant QLineEdit::inputMethodQuery(Qt::InputMethodQuery property, QVariant arg
return d->adjustedControlRect(d->control->anchorRect());
case Qt::ImFont:
return font();
case Qt::ImAbsolutePosition:
case Qt::ImCursorPosition: {
const QPointF pt = argument.toPointF();
if (!pt.isNull())

View File

@ -2250,6 +2250,11 @@ void tst_QLineEdit::cursorPositionChanged()
input.simulate(testWidget);
QCOMPARE(lastCursorPos, lastPos);
QCOMPARE(newCursorPos, newPos);
QInputMethodQueryEvent queryEvent(Qt::ImCursorPosition | Qt::ImAbsolutePosition);
QApplication::sendEvent(testWidget, &queryEvent);
QCOMPARE(queryEvent.value(Qt::ImCursorPosition).toInt(), newPos);
QCOMPARE(queryEvent.value(Qt::ImAbsolutePosition).toInt(), newPos);
}
void tst_QLineEdit::selectedText()