Re: web server connection
You can use blocked mode (from QIODevice::waitForReadyRead), but best way of code is use two function Y and Z. Where Y is first part of X. And Z is second (Also you can use signals|and slot). Example of code that i'm use:
A (called from Y):
Code:
reply = manager.get(QNetworkRequest(apiUrl));
connect(reply, SIGNAL(finished()),this, SLOT(on_replyfinish()));
connect(reply, SIGNAL(readyRead()), this, SLOT(on_read()));
connect(reply, SIGNAL(sslErrors(QList<QSslError>)), reply, SLOT(ignoreSslErrors()));
on_read():
Code:
void MainWindow::on_read()
{
result+=reply->readAll();
}
on_replyfinish():
Code:
void MainWindow::on_replyfinish()
{//oh, called on error or when all data is readed.
if(reply->error()!=QNetworkReply::NoError)
{
//error handle
}
else
{
Z();
}
}
Re: web server connection
thanks for reply.Now it is working.