Results 1 to 4 of 4

Thread: undefined reference to vtable in Threads.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2008
    Location
    Bangalore
    Posts
    10
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Platforms
    Unix/X11

    Default undefined reference to vtable in Threads.

    In the following code i got compilation erros like below

    /thread.cpp:20: undefined reference to `vtable for MyThread'

    thread.cpp:6: undefined reference to `vtable for MyThread'

    MyThread.h file is

    Qt Code:
    1. #ifndef MYTHREAD_H
    2. #define MYTHREAD_H
    3.  
    4. #include <QThread>
    5. #include <QObject>
    6.  
    7. class MyThread:public QThread
    8. {
    9. Q_OBJECT
    10. public:
    11. MyThread(QWidget* aParent);
    12. ~MyThread();
    13.  
    14. public slots:
    15. void Finished();
    16.  
    17. protected:
    18. void run();
    19. };
    20.  
    21. #endif //MYTHREAD_H
    To copy to clipboard, switch view to plain text mode 

    and MyThread.cpp is
    Qt Code:
    1. #include "thread.h"
    2. #include <iostream.h>
    3. #include <QMetaType>
    4.  
    5.  
    6. MyThread::MyThread(QWidget* aParent)
    7. {
    8. qRegisterMetaType<MyThread*>("MyThread");
    9. QObject::connect(this,SIGNAL(finished()),this,SLOT(Finished()));
    10. if(!isRunning())
    11. {
    12. start();
    13. }
    14. else
    15. {
    16. return;
    17. }
    18. }
    19.  
    20. MyThread::~MyThread()
    21. {
    22.  
    23. }
    24.  
    25. void MyThread::run()
    26. {
    27. cout <<"Hello :" << endl;
    28. }
    29.  
    30.  
    31. void MyThread::Finished()
    32. {
    33. cout << "In Finishes:" << endl;
    34. }
    To copy to clipboard, switch view to plain text mode 
    and main.cpp is

    Qt Code:
    1. int main(int argc,char* argv[])
    2. {
    3. QtopiaApplication app(argc,argv);
    4.  
    5. QWidget* lWidget = new QWidget;
    6. lWidget->setGeometry(0,0,240,320);
    7.  
    8. MyThread* lThread = new MyThread(lWidget);
    9.  
    10. Widget->show();
    11.  
    12. return app.exec();
    13. }
    To copy to clipboard, switch view to plain text mode 


    Now whts the problem in above code and wts the reason for that.
    Last edited by jpn; 6th February 2009 at 13:34. Reason: missing [code] tags

Similar Threads

  1. how to add static library into qmake
    By Namrata in forum Qt Tools
    Replies: 1
    Last Post: 20th November 2007, 17:33
  2. MS Sql native driver??
    By LordQt in forum Qt Programming
    Replies: 4
    Last Post: 9th October 2007, 13:41
  3. error undefined reference ...............
    By amit_pansuria in forum Qt Programming
    Replies: 2
    Last Post: 8th June 2007, 14:28
  4. how to correctly compile threads support?
    By srhlefty in forum Installation and Deployment
    Replies: 9
    Last Post: 25th June 2006, 19:15
  5. Strange error while using Q3Canvas
    By Kapil in forum Newbie
    Replies: 13
    Last Post: 15th June 2006, 19:36

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.