Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

slot not being called by QFutureWatcher



  • I have a function that runs the following ioStart() task with QtConcurrent::run() and when it is finished, the slot MainWindow::ioFinished() doesn't get called.

    {   
        QFutureWatcher<int> watcher;
    
        connect(&watcher, &QFutureWatcher<int>::finished, this,
            &MainWindow::ioFinished);
    
        QFuture<int> future = QtConcurrent::run(this, &MainWindow::ioStart, name);
    
        watcher.setFuture(future);    
    }
    

    I have it defined in the cpp and in the MainWindow.h ...

    public slots:
        void ioFinished();
    

    Anyone have ideas?



  • Ugh, thanks, that was it.



  • Is that allocation of the watcher accurate? If so, it goes out of scope immediately after the call to setFuture().



  • Ugh, thanks, that was it.


Log in to reply