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)
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With