diff --git a/src/plugins/python/python/option/interpreterwidget.cpp b/src/plugins/python/python/option/interpreterwidget.cpp index c0f0d9f4c..8b88ecf1a 100644 --- a/src/plugins/python/python/option/interpreterwidget.cpp +++ b/src/plugins/python/python/option/interpreterwidget.cpp @@ -154,7 +154,7 @@ void InterpreterWidget::setupUi() d->interpreterComboBox = new DComboBox(); d->interpreterComboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); QObject::connect(d->interpreterComboBox, &DComboBox::currentTextChanged, - this, &InterpreterWidget::setPackageData); + this, &InterpreterWidget::updatePackageData); d->selectCustomInterpreter = new DPushButton(tr("Browse"), this); d->removeCustomInterpreter = new DPushButton(tr("Remove"), this); @@ -253,12 +253,11 @@ void InterpreterWidget::updateUi() } } -void InterpreterWidget::setPackageData(const QString &text) +void InterpreterWidget::updatePackageData() { - QString cmd = "pip list"; - if (text.indexOf("python3") > -1) { - cmd = "pip3 list"; - } + auto param = qvariant_cast(d->interpreterComboBox->currentData(Qt::UserRole + 1)); + QString cmd = param.path + " -m pip list"; + QtConcurrent::run(this, &InterpreterWidget::findPackages, cmd); } diff --git a/src/plugins/python/python/option/interpreterwidget.h b/src/plugins/python/python/option/interpreterwidget.h index f8be7954a..b866ebb6e 100644 --- a/src/plugins/python/python/option/interpreterwidget.h +++ b/src/plugins/python/python/option/interpreterwidget.h @@ -68,7 +68,7 @@ public slots: bool getControlValue(QMap &map); void setControlValue(const QMap &map); - void setPackageData(const QString &text); + void updatePackageData(); void findPackages(const QString &cmd); InterpreterWidgetPrivate *const d;