Qt-interest Archive, March 2002
Q_OBJECT and Inheritance (Again )
Message 1 in thread
Hello again,
You show me some errors and ambiguities in my mail.
The problem is that I only want to show you the problem essence, my
real code is more complicated and it obscures the problem essence so I
write an (Wrong) skeleton in a message. Sorry, I think now is
correct.
class A
{
Q_OBJECT
(...)
public slots:
virtual void mySlot()
};
class B : public A
{
Q_OBJECT
(...)
};
class C
{
A* ARef;
public:
C(A& _ARef) {ARef = &_ARef}
A* getARef() {return ARef}
};
class X
{
Q_OBJECT
C* CInstance;
public:
X(A& _AParam)
{
CInstance = new C(*_AParam);
}
signals:
void mySignal();
};
X::function(...)
{
(...)
connect(this, SIGNAL(mySignal()), CInstance->getARef(), SLOT(mySlot()));
(...)
}
I Instantiate X at this form:
B BInstance;
X XInstance(BInstance);
XInstance.function();
I have this message from QT:
No such slot B::mySlot() !!!.
^^^
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! Look specialy an "B::" the problem is I need "A::" !!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Thanks all.
--
[ signature omitted ]
Message 2 in thread
Hi Shadow,
I think your A class should inherit QObject as well as
having the Q_OBJECT macro and moc'ked:-
class A: public QObject
Dave
Message 3 in thread
Dave Porritt wrote:
> Hi Shadow,
>
> I think your A class should inherit QObject as well as
> having the Q_OBJECT macro and moc'ked:-
>
> class A: public QObject
>
and class X also... :-)
JK
>
> Dave
>
> --
> List archive and information: http://qt-interest.trolltech.com