diff options
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/kernel/qaction.cpp | 11 | ||||
-rw-r--r-- | src/widgets/widgets/qtoolbutton.cpp | 7 |
2 files changed, 9 insertions, 9 deletions
diff --git a/src/widgets/kernel/qaction.cpp b/src/widgets/kernel/qaction.cpp index 9fbcf28aad..4dd10720d6 100644 --- a/src/widgets/kernel/qaction.cpp +++ b/src/widgets/kernel/qaction.cpp @@ -58,14 +58,9 @@ QT_BEGIN_NAMESPACE static QString qt_strippedText(QString s) { s.remove( QString::fromLatin1("...") ); - int i = 0; - while (i < s.size()) { - ++i; - if (s.at(i-1) != QLatin1Char('&')) - continue; - if (i < s.size() && s.at(i) == QLatin1Char('&')) - ++i; - s.remove(i-1,1); + for (int i = 0; i < s.size(); ++i) { + if (s.at(i) == QLatin1Char('&')) + s.remove(i, 1); } return s.trimmed(); } diff --git a/src/widgets/widgets/qtoolbutton.cpp b/src/widgets/widgets/qtoolbutton.cpp index 93f0b60058..69432761e6 100644 --- a/src/widgets/widgets/qtoolbutton.cpp +++ b/src/widgets/widgets/qtoolbutton.cpp @@ -897,7 +897,12 @@ void QToolButton::setDefaultAction(QAction *action) return; if (!actions().contains(action)) addAction(action); - setText(action->text()); + QString buttonText = action->iconText(); + // If iconText() is generated from text(), we need to escape any '&'s so they + // don't turn into shortcuts + if (QActionPrivate::get(action)->iconText.isEmpty()) + buttonText.replace(QLatin1String("&"), QLatin1String("&&")); + setText(buttonText); setIcon(action->icon()); #ifndef QT_NO_TOOLTIP setToolTip(action->toolTip()); |