Qt-interest Archive, March 2002
Q_OBJECT and Inheritance (Again)
Message 1 in thread
Sorry but last message have an errata: :(,
Hello All,
I have a code like this:
class A
{
Q_OBJECT
(...)
public slots:
virtual void mySlot()
};
class B
{
Q_OBJECT
(...)
};
class C
{
A* ARef;
public:
C(A& _ARef) {ARef = &_ARef}
A* getARef() {return ARef}
};
class X
{
A* AInstance;
C* CInstance;
public:
X()
{
AInstance = new A;
CInstance = new C(*A);
}
X::foreignFunction(...)
{
(...)
connect(this, SIGNAL(mySignal()), C->getARef(), SLOT(mySlot()));
(...)
}
My problem is that when i did such connection qDebugger says me:
(- Corrected Errata -)
No such slot C::mySlot() !!!.
I Know i cant reimplement mySlot() slot in C class but isn't my
prurpose cos C class is "client class" that can be developed by thirth
party developers and I don't want explain they mySlot purpose.
Thanks to Ebner Andreas !
Thanks for your support.
--
[ signature omitted ]
Message 2 in thread
Shadow wrote:
> Sorry but last message have an errata: :(,
>
> Hello All,
>
> I have a code like this:
>
> class A
> {
> Q_OBJECT
> (...)
>
> public slots:
> virtual void mySlot()
> };
>
> class B
> {
> Q_OBJECT
> (...)
>
> };
>
> class C
> {
> A* ARef;
> public:
> C(A& _ARef) {ARef = &_ARef}
> A* getARef() {return ARef}
> };
>
> class X
> {
> A* AInstance;
> C* CInstance;
> public:
> X()
> {
> AInstance = new A;
> CInstance = new C(*A);
> }
>
> X::foreignFunction(...)
> {
> (...)
> connect(this, SIGNAL(mySignal()), C->getARef(), SLOT(mySlot()));
> (...)
> }
>
Where mySignal() is defined? If in class X body, you forgot about Q_OBJECT
macro.
JK
>
> My problem is that when i did such connection qDebugger says me:
> (- Corrected Errata -)
> No such slot C::mySlot() !!!.
>
> I Know i cant reimplement mySlot() slot in C class but isn't my
> prurpose cos C class is "client class" that can be developed by thirth
> party developers and I don't want explain they mySlot purpose.
>
> Thanks to Ebner Andreas !
> Thanks for your support.
>
> --
> Best regards,
> Shadow mailto:jordifernandez@tavil.net
>
> --
> List archive and information: http://qt-interest.trolltech.com
Message 3 in thread
From: Shadow [mailto:jordifernandez@tavil.net]
>
> class A
> {
> Q_OBJECT
> public slots:
> virtual void mySlot()
> };
>
> class C
> {
> A* ARef;
> public:
> C(A& _ARef) {ARef = &_ARef}
> A* getARef() {return ARef}
> };
>
> class X
> {
> A* AInstance;
> C* CInstance;
> public:
> X()
> {
> AInstance = new A;
> CInstance = new C(*A);
> }
>
> X::foreignFunction(...)
> {
> (...)
> connect(this, SIGNAL(mySignal()), C->getARef(), SLOT(mySlot()));
> (...)
> }
IMHO, you should use "CInstance->getARef()" instead of "C->getARef()"!?
But normally, your compiler should complain about using "C->" as C is a
class rather than an instance!?
--
[ signature omitted ]