Hello,

I'm trying to download a webpage using the QNetworkAccessManager but I always get strange build errors..

Here is my code:
Qt Code:
  1. #include <QtCore/QCoreApplication>
  2. #include "downloadpage.h"
  3.  
  4. int main(int argc, char *argv[])
  5. {
  6. QCoreApplication a(argc, argv);
  7.  
  8. DownloadPage downloadPage;
  9. downloadPage.startDownload();
  10.  
  11. return a.exec();
  12. }
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. #ifndef DOWNLOADPAGE_H
  2. #define DOWNLOADPAGE_H
  3.  
  4. #include <Qt/QtNetwork>
  5. #include <QDebug>
  6.  
  7. class DownloadPage:QObject
  8. {
  9. Q_OBJECT
  10.  
  11. public:
  12. DownloadPage();
  13. void startDownload();
  14.  
  15. private slots:
  16. void downloadComplete(QNetworkReply *reply);
  17.  
  18. private:
  19. QNetworkAccessManager *manager;
  20. };
  21.  
  22. #endif // DOWNLOADPAGE_H
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. #include "downloadpage.h"
  2.  
  3. DownloadPage::DownloadPage()
  4. {
  5. qDebug()<<"Download Page constructor called";
  6. manager = new QNetworkAccessManager(this);
  7. connect(manager,SIGNAL(finished(QNetworkReply*)),this,SLOT(downloadComplete(QNetworkReply*)));
  8. }
  9.  
  10. void DownloadPage::startDownload(){
  11. qDebug()<<"Downloading Page...";
  12. manager->get(QNetworkRequest(QUrl("http://www.google.ch")));
  13. qDebug()<<"Page call end but not finished yet";
  14. }
  15.  
  16. void DownloadPage::downloadComplete(QNetworkReply *reply){
  17. qDebug()<<"Page call finished";
  18. }
To copy to clipboard, switch view to plain text mode 

and my build errors are:
Qt Code:
  1. debug/downloadpage.o: In function `DownloadPage':
  2. D:\Desktop\ComeOn-build-desktop-Qt_4_8_1_for_Desktop_-_MinGW__Qt_SDK__Debug/../ComeOn/downloadpage.cpp:6: undefined reference to `_imp___ZN21QNetworkAccessManagerC1EP7QObject'
  3. D:\Desktop\ComeOn-build-desktop-Qt_4_8_1_for_Desktop_-_MinGW__Qt_SDK__Debug/../ComeOn/downloadpage.cpp:6: undefined reference to `_imp___ZN21QNetworkAccessManagerC1EP7QObject'
  4. debug/downloadpage.o:D:\Desktop\ComeOn-build-desktop-Qt_4_8_1_for_Desktop_-_MinGW__Qt_SDK__Debug/../ComeOn/downloadpage.cpp:12: undefined reference to `_imp___ZN15QNetworkRequestC1ERK4QUrl'
  5. debug/downloadpage.o:D:\Desktop\ComeOn-build-desktop-Qt_4_8_1_for_Desktop_-_MinGW__Qt_SDK__Debug/../ComeOn/downloadpage.cpp:12: undefined reference to `_imp___ZN21QNetworkAccessManager3getERK15QNetworkRequest'
  6. debug/downloadpage.o:D:\Desktop\ComeOn-build-desktop-Qt_4_8_1_for_Desktop_-_MinGW__Qt_SDK__Debug/../ComeOn/downloadpage.cpp:12: undefined reference to `_imp___ZN15QNetworkRequestD1Ev'
  7. debug/downloadpage.o:D:\Desktop\ComeOn-build-desktop-Qt_4_8_1_for_Desktop_-_MinGW__Qt_SDK__Debug/../ComeOn/downloadpage.cpp:12: undefined reference to `_imp___ZN15QNetworkRequestD1Ev'
  8. collect2: ld returned 1 exit status
  9. mingw32-make.exe[1]: *** [debug\ComeOn.exe] Error 1
  10. mingw32-make.exe: *** [debug] Error 2
  11. 21:36:03: The process "D:\QtSDK\mingw\bin\mingw32-make.exe" exited with code 2.
  12. Error while building project ComeOn (target: Desktop)
  13. When executing build step 'Make'
To copy to clipboard, switch view to plain text mode 

Does anybody have an idea?

Thanks!