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
#include "thread.h"
{
this->strCaminhoOff = strCaminhoOff;
this->strCaminhoPP = strCaminhoPP;
stop = false;
this->ind = ind;
}
void Thread::run()
{
qDebug() << "Executing a new independant thread, GUI is NOT blocked" << ind;
tempo.start();
int i;
for(i=0; i<1000000000; i++){
if(stop == false){
i++; i--;
}else break;
}
qDebug() << "\n" << i;
emit nova(strCaminhoOff, tempo.elapsed(), ind);
//exec();
}
#include "thread.h"
Thread::Thread(QObject *parent, QString strCaminhoOff, QString strCaminhoPP, int ind) : QThread(parent)
{
this->strCaminhoOff = strCaminhoOff;
this->strCaminhoPP = strCaminhoPP;
stop = false;
this->ind = ind;
}
void Thread::run()
{
qDebug() << "Executing a new independant thread, GUI is NOT blocked" << ind;
QTime tempo;
tempo.start();
int i;
for(i=0; i<1000000000; i++){
if(stop == false){
i++; i--;
}else break;
}
qDebug() << "\n" << i;
emit nova(strCaminhoOff, tempo.elapsed(), ind);
//exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks