Note that there are some explanatory texts on larger screens.

plurals
  1. POQT: unresolved external symbol while trying to get webpage source code
    text
    copied!<p>I started developing with Qt and I'm trying to get webpage source code. Here's what I have :</p> <p>mainwindow.cpp</p> <pre><code>#include "mainwindow.h" #include "ui_mainwindow.h" #include &lt;QString&gt; #include &lt;QNetworkRequest&gt; #include &lt;QNetworkReply&gt; #include &lt;QNetworkAccessManager&gt; #include &lt;QUrl&gt; MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui-&gt;setupUi(this); } MainWindow::~MainWindow() { delete ui; } /**/ class GetHTMLSource : public QObject { Q_OBJECT public: GetHTMLSource(); void GetSource(); public slots: void GetDone(QNetworkReply*); private: QNetworkAccessManager* NetManager; }; GetHTMLSource::GetHTMLSource() { NetManager = new QNetworkAccessManager(this); connect(NetManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(GetDone(QNetworkReply*))); } void GetHTMLSource::GetSource() { NetManager-&gt;get(QNetworkRequest(QUrl("http://stackoverflow.com"))); } void GetHTMLSource::GetDone(QNetworkReply* ReplyIn) { QByteArray DataIn=ReplyIn-&gt;readAll(); QString DataString(DataIn); //process str any way you like! } /**/ void MainWindow::on_pushButton_clicked() { GetHTMLSource Test; Test.GetSource(); } </code></pre> <p>mainwindow.h</p> <pre><code>#ifndef MAINWINDOW_H #define MAINWINDOW_H #include &lt;QMainWindow&gt; namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private slots: void on_pushButton_clicked(); private: Ui::MainWindow *ui; }; #endif // MAINWINDOW_H </code></pre> <p>.pro</p> <pre><code>QT += core gui TARGET = TestGetPageSource TEMPLATE = app SOURCES += main.cpp\ mainwindow.cpp HEADERS += mainwindow.h FORMS += mainwindow.ui QT += network </code></pre> <p>Errors are :</p> <blockquote> <p>mainwindow.obj:-1: error:LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall GetHTMLSource::metaObject(void)const " (?metaObject@GetHTMLSource@@UBEPBUQMetaObject@@XZ)</p> <p>mainwindow.obj:-1: error:LNK2001: unresolved external symbol "public: virtual void * __thiscall GetHTMLSource::qt_metacast(char const *)" (?qt_metacast@GetHTMLSource@@UAEPAXPBD@Z)</p> <p>mainwindow.obj:-1: error:LNK2001: unresolved external symbol "public: virtual int __thiscall GetHTMLSource::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@GetHTMLSource@@UAEHW4Call@QMetaObject@@HPAPAX@Z)</p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload