AaronMK
26th October 2007, 21:53
I am trying to connect to a signal in a base class. The pointer is the type of the base class but points to an object of the derived class. My classes are declared similar to the following:
class Base : public QObject
{
Q_OBJECT
public:
Base();
signals:
void BaseSignal(char Arg);
};
class DerivA : public Base
{
Q_OBJECT
public:
DerivA();
void Alert() { emit BaseSignal('A') };
};
class DerivB : public Base
{
Q_OBJECT
public:
DerivB();
void Alert() { emit BaseSignal('B') };
};
Connect fails if I pass a DerivA or DerivB pointer to a function like the following:
bool SomeObject::mbrConnect(Base *B)
{
return QObject::connect(B, SIGNAL(BaseSignal(char)), this, SLOT(Handler(char));
}
It seems it is too smart for its own good, being able to identify the real type of the Base pointer in the Connect Fail output message. For example, passing mbrConnect a DerivA pointer would output the following:
Object::connect: No such signal DerivA::BaseSignal(char)
How do I solve this?
class Base : public QObject
{
Q_OBJECT
public:
Base();
signals:
void BaseSignal(char Arg);
};
class DerivA : public Base
{
Q_OBJECT
public:
DerivA();
void Alert() { emit BaseSignal('A') };
};
class DerivB : public Base
{
Q_OBJECT
public:
DerivB();
void Alert() { emit BaseSignal('B') };
};
Connect fails if I pass a DerivA or DerivB pointer to a function like the following:
bool SomeObject::mbrConnect(Base *B)
{
return QObject::connect(B, SIGNAL(BaseSignal(char)), this, SLOT(Handler(char));
}
It seems it is too smart for its own good, being able to identify the real type of the Base pointer in the Connect Fail output message. For example, passing mbrConnect a DerivA pointer would output the following:
Object::connect: No such signal DerivA::BaseSignal(char)
How do I solve this?