Advertisement
Guest User

Untitled

a guest
Dec 19th, 2011
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1.  
  2. nam = new QNetworkAccessManager(this);
  3. QObject::connect(nam, SIGNAL(finished(QNetworkReply*)), this, SLOT(finishedSlot(QNetworkReply*)));
  4. QUrl url("http://rainisto.com/");
  5. QNetworkReply* reply = nam->get(QNetworkRequest(url));
  6.  
  7. void MyClass::finishedSlot(QNetworkReply* reply)
  8. {
  9. // Reading attributes of the reply
  10. // e.g. the HTTP status code
  11. QVariant statusCodeV = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
  12. // Or the target URL if it was a redirect:
  13. QVariant redirectionTargetUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
  14. // see CS001432 on how to handle this
  15. if (reply->error() == QNetworkReply::NoError)
  16. {
  17. // read data from QNetworkReply here
  18. QByteArray bytes = reply->readAll(); // bytes
  19. QString string = QString::fromUtf8(bytes); // string
  20. qDebug() << "REPLY" << string << "\n";
  21. }
  22. else
  23. {
  24. qDebug() << "ERROR:" << reply->error();
  25. }
  26. reply->deleteLater();
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement