So... i'm doing a Thread through Qthread
before Exec(), i need to do some previous IP TCP checks to some locations. I use my Run() function (that ends with the exec()) to do those previous checks. The problem is that i want to give the user the chance to go one way or another depending on the results of those checks.
So, inside my Run function i tried to call a QMessageBox, but the program crashes every time it has to open something related to QWidget from a QThread function related.
Any ideas why? Any ideas to know how to do what i'd like?
thanks
Edit: code
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
void doitThread::run() {
//Try to connect to someone first
socket = new QTcpSocket();
int i = 0;
while (socket->state()!=QAbstractSocket::ConnectedState && i<clients->count()){
fb->lineEdit("Prova de connexió amb "+clients->at(i));
socket->connectToHost(QHostAddress(clients->at(i)), 6999);
socket->waitForConnected(1000);
i++;
}
if (socket->state()!=QAbstractSocket::ConnectedState){ //id like to let the user decide what to do if i haven't been able to connect to anyone
bool decide=false;
askServer * ask = new askServer(parent, &decide); //This is similar to a message box class, click ok or cancel, and the result is saved in the bool parametre
ask.exec();
if (decide==false){
socket->close();
this->exit(0);
}
}
exec();
}
|