Results 1 to 5 of 5

Thread: Qthread + Q_object problem

  1. #1
    Join Date
    Nov 2009
    Posts
    39
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Qthread + Q_object problem

    Hi, i'm having some trouble introducing signals on a class that heritates from qthread,the class is this one:

    Qt Code:
    1. class TEjecutor:public QThread {
    2. Q_OBJECT
    3.  
    4. private:
    5. .
    6. .
    7. .
    8. .
    9. private slots:
    10. .
    11. .
    12. ..
    13.  
    14. and so on
    To copy to clipboard, switch view to plain text mode 

    i asign signals on the cpp file
    Qt Code:
    1. connect(http, SIGNAL(requestFinished(int, bool)),
    2. this, SLOT(httpRequestFinished(int, bool)));
    To copy to clipboard, switch view to plain text mode 

    and after when i compile i get this error:

    Qt Code:
    1. ./release\tejecutor.o:tejecutor.cpp:(.text+0x1fd2): undefined reference to `TEjecutor::staticMetaObject'
    2. ./release\tejecutor.o:tejecutor.cpp:(.text+0x261c): undefined reference to `TEjecutor::staticMetaObject'
    3. ./release\comunicacion.o:comunicacion.cpp:(.text+0x23ab): undefined reference to `vtable for TEjecutor'
    4. ./release\comunicacion.o:comunicacion.cpp:(.text+0x277b): undefined reference to `vtable for TEjecutor'
    5. collect2: ld returned 1 exit status
    6. mingw32-make[1]: *** [release\Zeus.exe] Error 1
    7. mingw32-make: *** [release] Error 2
    8. Exited with code 2.
    9. Error while building project Zeus
    10. When executing build step 'Make'
    To copy to clipboard, switch view to plain text mode 

    If i erase the "Q_Object" it builds perfectly but signals wont work.

    What can i do?

  2. #2
    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: Qthread + Q_object problem

    seems to me, that you have to clean your total project and remove also the Makefile. Then rebuild your application and all should work fine.

  3. The following user says thank you to Lykurg for this useful post:

    cae (28th November 2009)

  4. #3
    Join Date
    Nov 2009
    Posts
    39
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qthread + Q_object problem

    It's working

    thanks!

  5. #4
    Join Date
    Nov 2009
    Posts
    39
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qthread + Q_object problem

    Is there any problem with Threads+Signals from Qhttp??? i cant make it work when it is a Thread, but if i change it to a normal class instead of Thread, it works perfectly, otherwise signals dont arrive to my thread....

  6. #5
    Join Date
    Oct 2009
    Location
    Oakland, CA, USA
    Posts
    2
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Qthread + Q_object problem

    The QHttp instance needs to be created in the same thread that is performing the HTTP operation. If you create it outside, and invoke it from within a QRunnable, you won't get your signals.

Similar Threads

  1. Very strange socket programming problem
    By montylee in forum Qt Programming
    Replies: 5
    Last Post: 11th November 2008, 12:05
  2. Replies: 0
    Last Post: 26th September 2008, 21:33
  3. Problem in using QHttp with QTimer
    By Ferdous in forum Newbie
    Replies: 2
    Last Post: 6th September 2008, 12:48
  4. Replies: 16
    Last Post: 7th March 2006, 15:57
  5. Compilation problem, don't know why
    By yellowmat in forum Newbie
    Replies: 6
    Last Post: 2nd March 2006, 15: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.