0

I have this static class:

class NetworkTools {
public:

    static QMap<QString, QString>* getMbNames(const QString &html)
    {
        ...
        return result;
    }

    static QString download(const QUrl &url)
    {
        ...
        return result;
    };
};

And have MainWindow with this function on button click:

void MainWindow::on_updateSiteInfoBtn_clicked()
{
    ui->updateSiteInfoBtn->setEnabled(false);

    const QUrl productUrl("***");

    auto future = QtConcurrent::run(&NetworkTools::download, productUrl)
                    .then(QtFuture::Launch::Async, &NetworkTools::getMbNames);
                    .then(QtFuture::Launch::Sync, [=] {emit MainWindow::MakeMbListSignal(true);})
                //.then(QtFuture::Launch::Sync, &MainWindow::MakeMbList, true);
}

As you can see, I want to add values from getMbNames to Combobox at MainWindow (ui->siteInfoCmb). After that, I want to emit signal to MainWindow MakeMbListSignal or execute MakeMbList:

void MainWindow::MakeMbList(bool isSuccess)
{
    ui->siteInfoCmb->model()->sort(0);
    ui->siteInfoCmb->setCurrentIndex(0);
    ui->updateSiteInfoBtn->setVisible(!isSuccess);
    ui->siteInfoCmb->setVisible(isSuccess);
}

How can I do that?

SlimRG
  • 35
  • 6

0 Answers0