PDA

View Full Version : Qthread + Q_object problem



cae
27th November 2009, 16:32
Hi, i'm having some trouble introducing signals on a class that heritates from qthread,the class is this one:


class TEjecutor:public QThread {
Q_OBJECT

private:
.
.
.
.
private slots:
.
.
..

and so on


i asign signals on the cpp file

connect(http, SIGNAL(requestFinished(int, bool)),
this, SLOT(httpRequestFinished(int, bool)));

and after when i compile i get this error:


./release\tejecutor.o:tejecutor.cpp:(.text+0x1fd2): undefined reference to `TEjecutor::staticMetaObject'
./release\tejecutor.o:tejecutor.cpp:(.text+0x261c): undefined reference to `TEjecutor::staticMetaObject'
./release\comunicacion.o:comunicacion.cpp:(.text+0x2 3ab): undefined reference to `vtable for TEjecutor'
./release\comunicacion.o:comunicacion.cpp:(.text+0x2 77b): undefined reference to `vtable for TEjecutor'
collect2: ld returned 1 exit status
mingw32-make[1]: *** [release\Zeus.exe] Error 1
mingw32-make: *** [release] Error 2
Exited with code 2.
Error while building project Zeus
When executing build step 'Make'

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

What can i do?

Lykurg
27th November 2009, 16:47
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.

cae
28th November 2009, 11:50
It's working

thanks!

cae
28th November 2009, 12:26
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.... :(

Olema
9th December 2009, 14:58
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.