The following code uses QT
's Network API to send HTTP request and get the response:
void AnotherHttpClient::finished(QNetworkReply *qNetworkReply)
{
qDebug() << qNetworkReply->readAll();
}
void AnotherHttpClient::get(QString url)
{
QNetworkAccessManager *man = new QNetworkAccessManager(this);
connect(man, &QNetworkAccessManager::finished, this, finished);
const QUrl qurl = QUrl(url);
QNetworkRequest request(qurl);
man->get(request);
}
I need to make this code synchronous and I need get method to return the qNetworkReply. How should I do this? BTW are there any other synchronous way to send Http request in QT?