many thanks Wysota..
Just to better understand, you mean that the code that follows
while(http->currentId() != 0)
{
}
while(http->currentId() != 0)
{
QCoreApplication::processEvents();
}
To copy to clipboard, switch view to plain text mode
is also incorrect ??
Then, about the second method, I would like you to suggest how to modify the first part of code. I well understand the "if block".
Is it correct like this ?
tT.setSingleShot(true);
connect(&tT, SIGNAL(timeout()), &q, SLOT(quit()));
connect(http, SIGNAL(finished(QNetworkReply*)),&q, SLOT(quit()));
//**********************
id = http->request(header, b);
//**********************
tT.start(5000); // 5s timeout
q.exec();
if(tT.isActive()){
//*****************
result = http->readAll();
//*****************
tT.stop();
} else {
// timeout
}
QHttp *http;
QEventLoop q;
QTimer tT;
tT.setSingleShot(true);
connect(&tT, SIGNAL(timeout()), &q, SLOT(quit()));
connect(http, SIGNAL(finished(QNetworkReply*)),&q, SLOT(quit()));
//**********************
id = http->request(header, b);
//**********************
tT.start(5000); // 5s timeout
q.exec();
if(tT.isActive()){
//*****************
result = http->readAll();
//*****************
tT.stop();
} else {
// timeout
}
To copy to clipboard, switch view to plain text mode
Many thanks in advance
Roby
Bookmarks