Hi all,

please I need your help. What I want to do is, the user introduce in a form a total time of running, and an interval time. In each interval of the total time, several values are sent and several values are received. In a progress bar the total time is showed.

When someone pressed the stop button or the total time is finished, it calls a function that stop the timeline and the timer and call another function that shows a file dialog to save all the values in a XML.

The problem is that there is something worng in the timer or in the timeline, because when i run and then press the stop button, the file dialog is shown, but if i cancel the file dialog quick, another file dialog is shown, is like the stopall function is called several times. When the progrees bar end, it don´t happen.

Here is the code:

Qt Code:
  1. void Controller_run::execute(){
  2.  
  3. int frequency = run->ui.leFrequency->text().toInt();
  4. int total = run->ui.leTotal->text().toInt();
  5.  
  6. timerFrequency = new QTimer(this);
  7. timeLine = new QTimeLine;
  8.  
  9. timeLine->setDuration(total);
  10. timeLine->setFrameRange(0, 150); // update every second
  11. timeLine->setLoopCount(1);
  12.  
  13. run->ui.progressBar->setRange(0, 150);
  14.  
  15. connect(timerFrequency, SIGNAL(timeout()), this, SLOT(send_receive()));
  16. connect(timeLine, SIGNAL(frameChanged(int)), run->ui.progressBar, SLOT(setValue(int)));
  17. run->ui.progressBar->setValue(0);
  18. connect(run->ui.btStop, SIGNAL (clicked()), this, SLOT(stopall()));
  19. connect(timeLine, SIGNAL(finished()), this, SLOT(stopall()));
  20.  
  21. timerFrequency->start(frequency);
  22. timeLine->start();
  23. }
  24.  
  25. void Controller_run::stopall(){
  26.  
  27. timerFrequency->deleteLater();
  28. timeLine->stop();
  29.  
  30. run->ui.btRun->setEnabled("true");
  31. run->ui.btStop->setDisabled("true");
  32.  
  33. save_xml_file();
  34. }
To copy to clipboard, switch view to plain text mode 

Please help me, i am desperated.

Thanks in advanced.