Hello over there.
I have a couple of threads running on my program. So, i need finish one of them when a click a button.
I've tried use quit() and exit(), but didn't work. For now, i am setting true to a bool in class Thread that reaches the end of code, but i need another method.
Thanks all
Here is code for now
Qt Code:
  1. #include "thread.h"
  2.  
  3.  
  4. Thread::Thread(QObject *parent, QString strCaminhoOff, QString strCaminhoPP, int ind) : QThread(parent)
  5. {
  6. this->strCaminhoOff = strCaminhoOff;
  7. this->strCaminhoPP = strCaminhoPP;
  8. stop = false;
  9. this->ind = ind;
  10. }
  11.  
  12. void Thread::run()
  13. {
  14. qDebug() << "Executing a new independant thread, GUI is NOT blocked" << ind;
  15. QTime tempo;
  16. tempo.start();
  17. int i;
  18. for(i=0; i<1000000000; i++){
  19. if(stop == false){
  20. i++; i--;
  21. }else break;
  22. }
  23.  
  24. qDebug() << "\n" << i;
  25.  
  26. emit nova(strCaminhoOff, tempo.elapsed(), ind);
  27.  
  28. //exec();
  29. }
To copy to clipboard, switch view to plain text mode