Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- nam = new QNetworkAccessManager(this);
- QObject::connect(nam, SIGNAL(finished(QNetworkReply*)), this, SLOT(finishedSlot(QNetworkReply*)));
- QUrl url("http://rainisto.com/");
- QNetworkReply* reply = nam->get(QNetworkRequest(url));
- void MyClass::finishedSlot(QNetworkReply* reply)
- {
- // Reading attributes of the reply
- // e.g. the HTTP status code
- QVariant statusCodeV = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
- // Or the target URL if it was a redirect:
- QVariant redirectionTargetUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
- // see CS001432 on how to handle this
- if (reply->error() == QNetworkReply::NoError)
- {
- // read data from QNetworkReply here
- QByteArray bytes = reply->readAll(); // bytes
- QString string = QString::fromUtf8(bytes); // string
- qDebug() << "REPLY" << string << "\n";
- }
- else
- {
- qDebug() << "ERROR:" << reply->error();
- }
- reply->deleteLater();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement