class DownloadPage:QObject{Q_OBJECTprivate slots: replyFinished(QNetworkReply* reply){ if(reply->error()==QNetworkReply::NoError) { html = QString(reply->readAll()); emit EndLoad(html); } else qDebug()<<"Error load page"; }signals:void EndLoad(QString);public: DownloadPage(QUrl _url){ url = _url; manager = new QNetworkAccessManager(this); connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*))); manager->get(QNetworkRequest(url));}private: QNetworkAccessManager *manager ; QString html; };
DownloadPage *d = new DownloadPage(QUrl("http://google.com"));connect(d,EndLoad(QString),this,вашафункция(QString));void вашафункция(QString str){qDebug()<<str;}