borker
16th April 2009, 15:48
Hi everyone, this is probably a newbie question, but I couldn't readily find an answer so would like to ask the group for help.
I have a class hierarchy like the following:
namespace A {
class GenericService {
public :
void sendQuery();
protected slot:
void receiveData(QByteArray &data);
}
}
void GenericService::sendQuery()
{
/* do a bunch of stuff that results in a query being sent through RemoteService */
connect (RemoteService, SIGNAL(data(QByteArray)), this, SLOT(receiveData(QByteArray));
}
namespace B {
class SomeServiceType : public GenericService {
public :
/* some specialized functions */
}
class MoreSpecificServiceType : public SomeServiceType {
public :
/* more specialized functions */
}
}
My problem is that when I execute a query from an instance of MoreSpecificServiceType the connect fails to find the slot B::SomeServiceType::receiveData unless I specifically create that function, which then hides the default behavior of A::GenericService::receiveData which is what I want to have actually handle this signal. I'd have thought that the specialized classes would inherit the appropriate slot from the original base class and I'd not need to reimplement it. Can anyone let me know what the correct approach here is? or have I just made a general mistake someone can point out?
many thanks for your help
Nathan
I have a class hierarchy like the following:
namespace A {
class GenericService {
public :
void sendQuery();
protected slot:
void receiveData(QByteArray &data);
}
}
void GenericService::sendQuery()
{
/* do a bunch of stuff that results in a query being sent through RemoteService */
connect (RemoteService, SIGNAL(data(QByteArray)), this, SLOT(receiveData(QByteArray));
}
namespace B {
class SomeServiceType : public GenericService {
public :
/* some specialized functions */
}
class MoreSpecificServiceType : public SomeServiceType {
public :
/* more specialized functions */
}
}
My problem is that when I execute a query from an instance of MoreSpecificServiceType the connect fails to find the slot B::SomeServiceType::receiveData unless I specifically create that function, which then hides the default behavior of A::GenericService::receiveData which is what I want to have actually handle this signal. I'd have thought that the specialized classes would inherit the appropriate slot from the original base class and I'd not need to reimplement it. Can anyone let me know what the correct approach here is? or have I just made a general mistake someone can point out?
many thanks for your help
Nathan