[SOLVED] Get remote web code



  • 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 toQNetworkRequest::QNetworkRequest(QUrl const&)'
    mainwindow.cpp:15: error: undefined reference to QNetworkAccessManager::get(QNetworkRequest const&)' mainwindow.cpp:15: error: undefined reference toQNetworkRequest::~QNetworkRequest()'


  • Lifetime Qt Champion

    Hi,

    Did you added

    @QT += network@

    To your pro file ?

    Though it should be in by default IIRC



  • no, I have not added. in which files should be placed? and in what position? thank you.


  • Moderators

    It needs to be added to your project file which is named after your project and has .pro as filename extension.



  • 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.



  • I tried it on another pc and it works , thanks a lot to everyone.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.