I have a problem while working with an object of QNetworkAccessManager class. I want to send a POST request to a web server. My code is
QNetworkAccessManager *manager;
manager = new QNetworkAccessManager ();
QNetworkRequest req;
req.setUrl(QUrl("http://example.com"));
//Configure the parameters for the post request:
QByteArray postData;
postData.append("Login=log_name&");
postData.append("Password=some_pass");
//Now create a QCookieJar:
manager->setCookieJar(new QNetworkCookieJar(manager));
//Define the Request-url:
connect (manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(replyFinish (QNetworkReply *)));
//Send the request:
manager->post(req, postData);
The code of the used SLOT is:
void MainWindow::replyFinish(QNetworkReply *reply)
{
QString answer = QString::fromUtf8(reply->readAll());
qDebug () << answer;
}
The problem is that the answer is an empty string,but i believe it should be some html-code that describes acceptance or rejection of the authorization.
Thank you for your help.