diff --git a/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.cpp b/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.cpp index 432a22fec1c..956b5f2109b 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.cpp +++ b/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.cpp @@ -1116,11 +1116,8 @@ void ComboBoxField::setup(JsonFieldPage *page, const QString &name) selectionModel()->blockSignals(true); w->blockSignals(false); }); - page->registerObjectAsFieldWithName(name, selectionModel(), &QItemSelectionModel::selectionChanged, [this]() { - const QModelIndex i = selectionModel()->currentIndex(); - if (i.isValid()) - return i.data(ValueRole); - return QVariant(); + page->registerObjectAsFieldWithName(name, w, QOverload::of(&QComboBox::activated), [w]() { + return w->currentData(ValueRole); }); QObject::connect(selectionModel(), &QItemSelectionModel::selectionChanged, page, [page]() { emit page->completeChanged(); @@ -1143,6 +1140,13 @@ void ComboBoxField::initializeData(MacroExpander *expander) w->setCurrentIndex(selectionModel()->currentIndex().row()); } +QVariant ComboBoxField::toSettings() const +{ + if (auto w = qobject_cast(widget())) + return w->currentData(ValueRole); + return {}; +} + void IconListField::setup(JsonFieldPage *page, const QString &name) { auto w = qobject_cast(widget()); diff --git a/src/plugins/projectexplorer/jsonwizard/jsonfieldpage_p.h b/src/plugins/projectexplorer/jsonwizard/jsonfieldpage_p.h index 62db37aff65..6e91500b8eb 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonfieldpage_p.h +++ b/src/plugins/projectexplorer/jsonwizard/jsonfieldpage_p.h @@ -236,10 +236,11 @@ private: class ComboBoxField : public ListField { -public: +private: void setup(JsonFieldPage *page, const QString &name) override; QWidget *createWidget(const QString &displayName, JsonFieldPage *page) override; void initializeData(Utils::MacroExpander *expander) override; + QVariant toSettings() const override; }; class IconListField : public ListField