diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2023-05-16 12:59:43 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2023-05-17 00:25:40 +0200 |
commit | fda4da6df96f336d03ac1d018cecea03cbf31627 (patch) | |
tree | b2f904caf6ed4ecc504157a3b8cca3d98e20f509 | |
parent | bc4e9e432a35594a9512d501dd520cf412eeda6b (diff) | |
download | qtbase-fda4da6df96f336d03ac1d018cecea03cbf31627.tar.gz |
shortcuteditor example: Don't reference null-action
The parent nodes of the leaf ShortcutEditorModelItem nodes
do not have an action item.
Pick-to: 6.5
Change-Id: If9f8554101974a96f95db048b1bd691f3e89a23a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r-- | examples/widgets/widgets/shortcuteditor/shortcuteditormodel.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/examples/widgets/widgets/shortcuteditor/shortcuteditormodel.cpp b/examples/widgets/widgets/shortcuteditor/shortcuteditormodel.cpp index 4355f029e1..612f1fb726 100644 --- a/examples/widgets/widgets/shortcuteditor/shortcuteditormodel.cpp +++ b/examples/widgets/widgets/shortcuteditor/shortcuteditormodel.cpp @@ -257,11 +257,11 @@ bool ShortcutEditorModel::setData(const QModelIndex &index, const QVariant &valu QString keySequenceString = value.toString(); ShortcutEditorModelItem *item = static_cast<ShortcutEditorModelItem *>(index.internalPointer()); QAction *itemAction = item->action(); - if (itemAction - && keySequenceString == itemAction->shortcut().toString(QKeySequence::NativeText)) - return true; - - itemAction->setShortcut(keySequenceString); + if (itemAction) { + if (keySequenceString == itemAction->shortcut().toString(QKeySequence::NativeText)) + return true; + itemAction->setShortcut(keySequenceString); + } Q_EMIT dataChanged(index, index); if (keySequenceString.isEmpty()) |