QObject::connect simply "rejects" my object at compile-time(!)
-
C is a QObject derived class, I can use it successfully.
I get a compilation error on the "connect". If i'd change "this->controller", to "this", on the target, it will work fine. Something about the this->controller as the recipient causes this not to compile. I realize it must be something stupid, but the cause evades me.
@MyClass::MyClass(C * controller)
: QThread(NULL)
{
this->controller = controller;
QObject::connect(this, SIGNAL(OnResponse(ResponseClass*)), this->controller, SLOT(OnResponse(ResponseClass*))); // <---- "Compiler error: " error: no matching function for call to...."
}@ -
Yes, this is the reason. The connect method takes a QObject pointer as the third argument. As long as the header file of class C is not included, the compiler does not know about the fact that you inherited from QObject and thus treads the pointer like a void pointer (at least kind-of in the sense of the error message, the compiler gurus may add some additional insight).
Be aware, that without including C's header file in MyClass implementation, you would never be able to call methods on the this->controller pointer.