You can use a local event loop using QEventLoop
and connecting the signal finished of your QNetworkAccessManager
to the quit slot of QEventLoop
. This way when the post is finished, the local event loop quits and the rest gets executed :
QNetworkAccessManager *networkManager = new QNetworkAccessManager(this);
networkManager->post(QNetworkRequest(serviceUrl), postData);
QEventLoop loop;
loop.connect(networkManager, SIGNAL(finished(QNetworkReply*)), SLOT(quit()));
loop.exec();
//...
I should not that it's the standard pattern for "blocking wait without blocking the UI".