Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Object::connect: No such signal

I have a problem to create custom slots/signal with a struct. I have the following code :

qRegisterMetaType<namespace::myClassA::aStruct>();
QObject::connect(&myClassA, SIGNAL(theSignal(myClassA::aStruct)),
                  &myClassB, SLOT(theSlot(myClassA::aStruct)));

When running the program I got :

Object::connect: No such signal NameSpace::myClassA::theSignal(myClassA::aStruct)
Object::connect:  (receiver name: 'NameSpace__CLASSNAME')

How do I resolved this problem?

PS: The slot and the signal have been properly declared in header files file Q_SIGNALS and Q_SLOTS keywords, with the correct argument (aStruct)

like image 845
peterphonic Avatar asked Dec 09 '22 17:12

peterphonic


2 Answers

Types used in signal/slot connections must be fully 'scoped' because the method call is converted into text, so your connection call should look like this:

QObject::connect(&myClassA, SIGNAL(theSignal(namespace::myClassA::aStruct)),
                 &myClassB, SLOT(theSlot(namespace::myClassA::aStruct)));

You'll probably have to update the signal/slot declaration arguments to match.

like image 197
cmannett85 Avatar answered Dec 11 '22 10:12

cmannett85


I have found the solution of signal slot: The declaration and call of signal and slot functions were mismatching! As soon as I fixed them, the slot got called.

Here you may got all the possible way of mistake.

20 ways to debug Qt signals and slots

Hope, it helped a lot after reading this articlethis and will save your time.

like image 31
AB Bolim Avatar answered Dec 11 '22 10:12

AB Bolim