Results 1 to 3 of 3

Thread: Strange errors

  1. #1
    Join Date
    Jan 2009
    Posts
    29
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Strange errors

    OS: Ubuntu Linux 8.10 x64

    QT version: 4.4.3

    The code:

    Qt Code:
    1. #include <QApplication>
    2. #include <QHttp>
    3. #include <QString>
    4.  
    5. #include <iostream>
    6.  
    7. class Test: public QObject
    8. {
    9. Q_OBJECT
    10.  
    11. QHttp objQHttp;
    12.  
    13. public:
    14.  
    15. Test(QObject *parent= 0): QObject(parent), objQHttp("ftp.otenet.gr")
    16. {
    17. connect(&objQHttp, SIGNAL(dataReadProgress(int, int)), this, SLOT(DisplayProgress(int, int)));
    18.  
    19. objQHttp.get("/linux/ubuntu-releases/intrepid/ubuntu-8.10-desktop-amd64.iso");
    20. }
    21.  
    22.  
    23. private slots:
    24. void DisplayProgress(int done, int total)
    25. {
    26. std::cout<< done<< " of "<< total<< " has been downloaded so far\n";
    27. }
    28. };
    29.  
    30.  
    31. int main(int argc, char *argv[])
    32. {
    33. QApplication app(argc, argv);
    34.  
    35. Test obj(0);
    36.  
    37. app.exec();
    38.  
    39. return 0;
    40. }
    To copy to clipboard, switch view to plain text mode 

    with QT+= network added in the .pro file, produces:

    Qt Code:
    1. john@ubuntu:~/Projects/qt/test$ make
    2. g++ -Wl,--no-undefined -o test main.o -L/usr/lib -lQtGui -lQtNetwork -lQtCore -lpthread
    3. main.o: In function `main':
    4. main.cpp:(.text+0x77): undefined reference to `vtable for Test'
    5. main.cpp:(.text+0x117): undefined reference to `vtable for Test'
    6. main.o: In function `Test::~Test()':
    7. main.cpp:(.text._ZN4TestD1Ev[Test::~Test()]+0x14): undefined reference to `vtable for Test'
    8. collect2: ld returned 1 exit status
    9. make: *** [test] Error 1
    To copy to clipboard, switch view to plain text mode 

    How can this be fixed?

  2. #2
    Join Date
    Mar 2008
    Location
    Houston, Texas, USA
    Posts
    277
    Thanks
    9
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: Strange errors

    add this to it

    Qt Code:
    1. #include "test.moc"
    To copy to clipboard, switch view to plain text mode 

    Add it before the main() and after the Test class. You should seperate this.
    Qt-4.7.3 | Gentoo ~amd64 | KDE-4.7
    Aki IRC Client for KDE4 | Qt Documentation

  3. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Strange errors

    ...or better use separate files. One for the main function, one test.cpp and one text.h. This would I prefer.

Similar Threads

  1. Very strange socket programming problem
    By montylee in forum Qt Programming
    Replies: 5
    Last Post: 11th November 2008, 12:05
  2. strange QT error out of nowhere
    By Penut in forum Qt Programming
    Replies: 5
    Last Post: 14th August 2008, 01:46
  3. [Win32/VC++ 8.0] Strange problems with qrc_*.cpp files
    By mloskot in forum Installation and Deployment
    Replies: 6
    Last Post: 6th March 2006, 10:28

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.