Object::connect: No such signal

peterphonic picture peterphonic · Feb 8, 2013 · Viewed 26.6k times · Source

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)

Answer

cmannett85 picture cmannett85 · Feb 8, 2013

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.