I used the advice from How can i get content of web-page to download a page using QT QNetworkAccessManager. Here is the code I have:
Header:
class WebAccessor : public QObject{
Q_OBJECT
public:
WebAccessor();
void fetch(const QString &url);
public slots:
void replyFinished(QNetworkReply *reply);
private:
QNetworkAccessManager *netManager_;
QString pageData_;
};
Cpp:
WebAccessor::WebAccessor(){
netManager_ = new QNetworkAccessManager(this);
connect(netManager_, SIGNAL(finished(QNetworkReply *)),
this, SLOT(replyFinished(QNetworkReply *)));
}
void WebAccessor::fetch(const QString &url){
netManager_->get(QNetworkRequest(QUrl(url)));
}
void WebAccessor::replyFinished(QNetworkReply *pReply){
QByteArray data = pReply->raedAll();
pageData_ = QString(data);
}
I have included the QtNetworkd4.lib in project's dependencies, but I get the following error:
error C2027: use of undefined type 'QNetworkReply'
Please let me know if I've missed anything... I think that I'm not linking the library properly.