Hi,

I'm having problems with QtConcurrent, how to pause execution of QtConcurrent function (thread) ?
I've tried QFuture setPaused(true) and pause() but that does not work. Let say I have code like this:

Qt Code:
  1. void MainWindow::on_pushButton_clicked() // run button
  2. {
  3. future = QtConcurrent::run(this, &MainWindow::my_func);
  4. watcher.setFuture(future);
  5. }
  6.  
  7. void MainWindow::on_pushButton_2_clicked() //pause button
  8. {
  9. future.pause();
  10. return;
  11. }
  12.  
  13. void MainWindow::my_func()
  14. {
  15. qDebug()<< "time-consuming code start";
  16. for (int i = 0; i < 8000; i++)
  17. {
  18. for (int j = 1; j< 1000; j++)
  19. {
  20. sum = sum * i / j;
  21. QApplication::processEvents();
  22.  
  23. }
  24. }
  25. qDebug()<< "time-consuming code end";
  26. }
To copy to clipboard, switch view to plain text mode 

When I press pause button my_func() still continues, thread is not paused. what am I doing wrong, how to pause execution of my_func ?
Thanks in advance.