Object :: connect: no such signal
I am having a problem creating custom slots / signals with structure. 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 to solve this problem?
PS: The slot and signal were correctly declared in the Q_SIGNALS and Q_SLOTS header files with the correct argument (aStruct)
source to share
The types used in signal / slot connections must be completely "copied" because the method call is converted to text, so your connection call should look like this:
QObject::connect(&myClassA, SIGNAL(theSignal(namespace::myClassA::aStruct)),
&myClassB, SLOT(theSlot(namespace::myClassA::aStruct)));
You may have to update the signal / slot declaration arguments to match.
source to share
I found a signal slot solution: Declaring and calling signal and slot functions are incompatible! Once I fixed them, the slot got its name.
You can get all possible ways of error here.
20 Ways to Debug Qt Signals and Slots
Hope it helped a lot after reading this article and saves you some time.
source to share