diff --git a/src/mnemonicattached.cpp b/src/mnemonicattached.cpp --- a/src/mnemonicattached.cpp +++ b/src/mnemonicattached.cpp @@ -203,8 +203,14 @@ m_richTextLabel.replace(QRegularExpression(QLatin1String("\\&([^\\&])")), QStringLiteral("\\1")); m_actualRichTextLabel = m_richTextLabel; m_mnemonicLabel = m_richTextLabel; - m_mnemonicLabel.replace(c, QLatin1String("&") % c); - m_richTextLabel.replace(QString(c), QLatin1String("") % c % QLatin1String("")); + const int mnemonicPos = m_mnemonicLabel.indexOf(c); + if (mnemonicPos > -1) { + m_mnemonicLabel.replace(mnemonicPos, 1, c); + } + const int richTextPos = m_richTextLabel.indexOf(c); + if (richTextPos > -1) { + m_richTextLabel.replace(richTextPos, 1, QLatin1String("") % c % QLatin1String("")); + } //remap the sequence of the previous shortcut if (otherMa) {