summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTianlu Shao <shaotianlu@uniontech.com>2021-08-09 20:38:04 +0800
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-08-10 12:58:17 +0000
commitd692bb4a845418366129e812afc6e69e7bf7b1b9 (patch)
treec6cdcf7e3b765342e697cbf5a5d270c456025b28 /src
parent09838d9cbd3f5c4c6f38bbd7a889d63e0226beeb (diff)
QCompleter: QCompleter unexpectedly changes QLineEdit text
When qcompleter and qlineedit are used together, the currentcompletion() of qcompleter is its first item by default. Therefore, when qlineedit makes the initial value, then selects the text and enters, qcompleter will modify the default first item to qlineedit text. The judgment that completionprefix() of the completer is not empty is modified and added here, because completionprefix() is always empty when there is no match. Fixes: QTBUG-20894 Change-Id: Id47f7f4da0a93d03a4e7b056ec731615b0803d13 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Tianlu Shao <shaotianlu@uniontech.com> (cherry picked from commit 0ef190fcc429405200d9f6063851726fcfb75637) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/widgets/qwidgetlinecontrol.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp
index 77c62b106b..2a0d97b914 100644
--- a/src/widgets/widgets/qwidgetlinecontrol.cpp
+++ b/src/widgets/widgets/qwidgetlinecontrol.cpp
@@ -1658,6 +1658,7 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event)
break;
#endif
if (!m_completer->currentCompletion().isEmpty() && hasSelectedText()
+ && !m_completer->completionPrefix().isEmpty()
&& textAfterSelection().isEmpty()) {
setText(m_completer->currentCompletion());
inlineCompletionAccepted = true;