diff --git a/src/plugins/qmldesigner/components/eventlist/eventlistdelegate.cpp b/src/plugins/qmldesigner/components/eventlist/eventlistdelegate.cpp index 939c36d338d..1db399b1539 100644 --- a/src/plugins/qmldesigner/components/eventlist/eventlistdelegate.cpp +++ b/src/plugins/qmldesigner/components/eventlist/eventlistdelegate.cpp @@ -27,8 +27,15 @@ QWidget *EventListDelegate::createEditor(QWidget *parent, { if (index.column() == EventListModel::shortcutColumn) { auto *editor = new ShortcutWidget(parent); - connect(editor, &ShortcutWidget::done, this, &EventListDelegate::commitAndClose); - connect(editor, &ShortcutWidget::cancel, this, &EventListDelegate::close); + connect(editor, &ShortcutWidget::done, this, [this, editor] { + auto that = const_cast(this); + emit that->commitData(editor); + emit that->closeEditor(editor); + }); + connect(editor, &ShortcutWidget::cancel, this, [this, editor] { + auto that = const_cast(this); + emit that->closeEditor(editor); + }); return editor; } else if (index.column() == EventListModel::connectColumn) { return nullptr; @@ -170,18 +177,4 @@ QSize EventListDelegate::sizeHint(const QStyleOptionViewItem &option, const QMod return QStyledItemDelegate::sizeHint(option, index); } -void EventListDelegate::commitAndClose() -{ - if (auto *editor = qobject_cast(sender())) { - emit commitData(editor); - emit closeEditor(editor); - } -} - -void EventListDelegate::close() -{ - if (auto *editor = qobject_cast(sender())) - emit closeEditor(editor); -} - } // namespace QmlDesigner. diff --git a/src/plugins/qmldesigner/components/eventlist/eventlistdelegate.h b/src/plugins/qmldesigner/components/eventlist/eventlistdelegate.h index 62ab74b617c..1589525df00 100644 --- a/src/plugins/qmldesigner/components/eventlist/eventlistdelegate.h +++ b/src/plugins/qmldesigner/components/eventlist/eventlistdelegate.h @@ -39,9 +39,6 @@ protected: QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; private: - void close(); - void commitAndClose(); - static bool hasConnectionColumn(QObject *parent); static QRect connectButtonRect(const QStyleOptionViewItem &option); };