Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Get remote web code

[SOLVED] Get remote web code

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 2.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    iacoposk8
    wrote on last edited by
    #1

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

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Did you added

      @QT += network@

      To your pro file ?

      Though it should be in by default IIRC

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • I Offline
        I Offline
        iacoposk8
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0
          • I Offline
            I Offline
            iacoposk8
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • I Offline
              I Offline
              iacoposk8
              wrote on last edited by
              #6

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

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved