diff --git a/src/widgets/widgets/qkeysequenceedit.cpp b/src/widgets/widgets/qkeysequenceedit.cpp index a2239f8c16..3dafb9396b 100644 --- a/src/widgets/widgets/qkeysequenceedit.cpp +++ b/src/widgets/widgets/qkeysequenceedit.cpp @@ -283,9 +283,8 @@ void QKeySequenceEdit::keyPressEvent(QKeyEvent *e) d->key[d->keyNum] = QKeyCombination::fromCombined(nextKey); d->keyNum++; - QKeySequence key(d->key[0], d->key[1], d->key[2], d->key[3]); - d->keySequence = key; - QString text = key.toString(QKeySequence::NativeText); + d->rebuildKeySequence(); + QString text = d->keySequence.toString(QKeySequence::NativeText); if (d->keyNum < QKeySequencePrivate::MaxKeyCount) { //: This text is an "unfinished" shortcut, expands like "Ctrl+A, ..." text = tr("%1, ...").arg(text); diff --git a/src/widgets/widgets/qkeysequenceedit_p.h b/src/widgets/widgets/qkeysequenceedit_p.h index 0ef664a21d..eaaaf63e8a 100644 --- a/src/widgets/widgets/qkeysequenceedit_p.h +++ b/src/widgets/widgets/qkeysequenceedit_p.h @@ -36,6 +36,8 @@ public: int translateModifiers(Qt::KeyboardModifiers state, const QString &text); void resetState(); void finishEditing(); + void rebuildKeySequence() + { keySequence = QKeySequence(key[0], key[1], key[2], key[3]); } QLineEdit *lineEdit; QKeySequence keySequence;