summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets
diff options
context:
space:
mode:
authorSona Kurazyan <sona.kurazyan@qt.io>2019-12-05 16:45:31 +0100
committerSona Kurazyan <sona.kurazyan@qt.io>2019-12-06 15:52:35 +0100
commit29adc0eed9b9dc3cce92f8acaaeaed3ab1bc6414 (patch)
tree39037a48dcd31e7df105a96ab536e5e0149c28c3 /src/widgets/widgets
parentca7033935a26e2a11c7d872a6673e828eddf49ca (diff)
Fix updating the text cursor position after editing
In some cases when editing the text (for example when removing the selected text, or pasting a text block) the text cursor position is updated, but its visual x position is not updated. This causes the next cursor movements to start from a wrong position. Force the update for those cases. Fixes: QTBUG-78479 Change-Id: Ia496be62beec58660f5e1695e5aafae09c79684e Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r--src/widgets/widgets/qwidgettextcontrol.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp
index 1c169c3325..83e2315c36 100644
--- a/src/widgets/widgets/qwidgettextcontrol.cpp
+++ b/src/widgets/widgets/qwidgettextcontrol.cpp
@@ -1283,6 +1283,8 @@ void QWidgetTextControlPrivate::keyPressEvent(QKeyEvent *e)
} else {
QTextCursor localCursor = cursor;
localCursor.deletePreviousChar();
+ if (cursor.d)
+ cursor.d->setX();
}
goto accept;
}
@@ -1322,9 +1324,13 @@ void QWidgetTextControlPrivate::keyPressEvent(QKeyEvent *e)
else if (e == QKeySequence::Delete) {
QTextCursor localCursor = cursor;
localCursor.deleteChar();
+ if (cursor.d)
+ cursor.d->setX();
} else if (e == QKeySequence::Backspace) {
QTextCursor localCursor = cursor;
localCursor.deletePreviousChar();
+ if (cursor.d)
+ cursor.d->setX();
}else if (e == QKeySequence::DeleteEndOfWord) {
if (!cursor.hasSelection())
cursor.movePosition(QTextCursor::NextWord, QTextCursor::KeepAnchor);