Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QFutureWatcher not work in for(;;) loop
Forum Updated to NodeBB v4.3 + New Features

QFutureWatcher not work in for(;;) loop

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 167 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mikeeeeee
    wrote on last edited by
    #1

    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))){
                qDebug()<<d<<QString::fromStdString(stdStringToMd5Hash(std::to_string(d)));
                result = d;
                signalStopFuter();
            }
        }));
        loop.exec();
        futureWatcher.waitForFinished();
        return result;
    }
    
    1 Reply Last reply
    0
    • M Offline
      M Offline
      Mikeeeeee
      wrote on last edited by
      #2

      it is work without QEventLoop loop;

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved