SigSlot conn from base classs to subclass
Hi,
I'm subclassing QHttp to a class called HttpSyncr.
I have the following slot declarations in HttpSyncr.h:
Code:
public slots:
void ReceiveResponseHeader(const QHttpResponseHeader& header);
void HttpRequestStarted(int id);
void HttpRequestFinished(int id, bool error);
This is how I'm connecting:
Code:
HttpSyncr
::HttpSyncr(QObject *parent
){
bool res = connect(this, SIGNAL(responseHeaderReceived(const QHttpResponseHeader&)), this, SLOT(ReceiveResponseHeader(const QHttpResponseHeader&)));
res = connect(this, SIGNAL(requestStarted(int)), this, SLOT(HttpRequestStarted(int)));
res = connect(this, SIGNAL(requestFinished(int, bool)), this, SLOT(HttpRequestFinished(int, bool)));
}
I figured that simply specifying 'this' as both source and target would be okay, but the slot is getting defined incorrectly. My debug output from the connect() function is:
Quote:
Object::connect: No such slot QHttp::ReceiveResponseHeader(QHttpResponseHeader)
Object::connect: No such slot QHttp::HttpRequestStarted(int)
Object::connect: No such slot QHttp::HttpRequestFinished(int,bool)
Is there a way to force MOC to know that the slot is actually in HttpSyncr and not the base class?
Steve
Re: SigSlot conn from base classs to subclass
Quote:
Is there a way to force MOC to know that the slot is actually in HttpSyncr and not the base class?
yes, use Q_OBJECT macro in your class.
Re: SigSlot conn from base classs to subclass
Well far out and golly jee wizz!
Thanks for that, I forgot about the illusive macro of doom.
It didn't occur to me that I'd need it in a subclass, but that's only header files of course. The subclass still needs to registered, all makes sense now.
Thanks again.
Steve