PDA

View Full Version : send own class reference throught signal



^NyAw^
10th January 2008, 16:46
Hi,

I have a own class that I need to emit using a signal. The problem is:



class classA
classA::classA()
{

}
public slots:
void aSlot(myClass&);

class classB: public classA
classB::classB()
{
bool bC = connect(pClassC,SIGNAL(aSignal(myClass&)),this,SLOT(aSlot(myClass&));
//This returns me "true"
};
classC* pClassC;


classA is a base Class. Has the slot to be called.
classB is derived from classA. Conects the classC signal with parent slot.
classC is a class that do something and emits a signal.

I had this working by passing the objects as value, but now, passing them by reference, the slot is not called.

Any idea what is happening?

Thanks,

^NyAw^
10th January 2008, 16:50
Hi,

I'm getting this:


Make sure 'myClass&' is registered using qRegisterMetaType().)



When I try to register it I'm getting this error when compiling:


c:\Qt\4.3.0\src\corelib\kernel\qmetatype.h(104): error C2558: class 'myClass' : no hay un constructor de copias disponible o éste se declaró como 'explicit'

in english maybe something like this:
c:\Qt\4.3.0\src\corelib\kernel\qmetatype.h(104): error C2558: class 'myClass' : there is not a copy constructor or this have been declared as 'explicit'


Thanks,

jpn
10th January 2008, 20:55
Are you sure you don't want to pass it as const reference?

^NyAw^
10th January 2008, 21:55
Hi,

I just added "const" to copy constructor and it works.



Are you sure you don't want to pass it as const reference?


How to do this and what is the difference?

Thanks,