How to implement pending completion of a request with QNetworkAccessManager in Qt?

0 like 0 dislike
9 views
In the Internet there are examples of how to implement it with the connection slot to the signal QNetworkReply::finished with QEventLoop and to QNetworkAccessManager::replyFinished not found. Inside handler after receiving the data based on them sent another request and it repeats.
Also wanted to know how you can put a timeout. If within 3 seconds failed to connect, then sends another request.
by | 9 views

1 Answer

0 like 0 dislike
QNetworkAccessManager manager; QEventLoop loop; QObject::connect(&manager, QOverload::of(&QNetworkAccessManager::finished), &loop, &QEventLoop::quit); ... loop.exec();

As for the timeout can call QTimer::singleShot(3000, &loop, &QEventLoop::quit);

PS: you should generally avoid locking, and process all slots in the class. Note that one instance of QNetworkAccessManager is limited to four simultaneous connections.
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
asked Apr 12, 2019 by terminator-light
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
33,908 users