[SOLVED] Get remote web code
-
wrote on 23 Feb 2015, 14:26 last edited by
hello everyone ..
I would pick up the HTML code for a page remotely. this is my code and related errors.[code]
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "QtNetwork/QtNetwork"MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);QNetworkAccessManager *manager = new QNetworkAccessManager(this); connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*))); manager->get(QNetworkRequest(QUrl("http://qtsoftware.com")));
}
[/code]mainwindow.cpp:11: error: undefined reference to
QNetworkAccessManager::QNetworkAccessManager(QObject*)' mainwindow.cpp:15: error: undefined reference to
QNetworkRequest::QNetworkRequest(QUrl const&)'
mainwindow.cpp:15: error: undefined reference toQNetworkAccessManager::get(QNetworkRequest const&)' mainwindow.cpp:15: error: undefined reference to
QNetworkRequest::~QNetworkRequest()' -
-
wrote on 23 Feb 2015, 15:58 last edited by
no, I have not added. in which files should be placed? and in what position? thank you.
-
wrote on 23 Feb 2015, 21:16 last edited by
It needs to be added to your project file which is named after your project and has .pro as filename extension.
-
wrote on 24 Feb 2015, 16:09 last edited by
thanks a lot, now runs without errors.
in the bottom of the document I added this slot:
[code]
void MainWindow::replyFinished(QNetworkReply *pReply)
{
QByteArray data=pReply->readAll();
QString str(data);
qWarning() << str;
}
[/code]but in the application otput not see anything, only ""
then enters into the slot but does not read anything. -
wrote on 25 Feb 2015, 17:40 last edited by
I tried it on another pc and it works , thanks a lot to everyone.
1/6