Important: Please read the Qt Code of Conduct -

QFutureWatcher not work in for(;;) loop

  • Hi.
    QFutureWatcher not work in for(;;) loop.
    Without a loop, this code works, but in an for(;;) loop, the program stops and does nothing. Why so and how to fix it?

    int MainWindow::checkVector(QVector<int> vector, std::string sdtMd5String)
        int result = 0;
        QFutureWatcher<void> futureWatcher;
        QEventLoop loop;
        connect ( this , &MainWindow::signalStopFuter, &futureWatcher, &QFutureWatcher<void>::cancel);
        futureWatcher.setFuture(QtConcurrent::map(vector,[&](const int& d){
            if(sdtMd5String == stdStringToMd5Hash(std::to_string(d))){
                result = d;
        return result;

  • it is work without QEventLoop loop;

Log in to reply