Saturday, August 09, 2014

Qt connect is complaining that it can't find slot in super class when connecting sub class

Got an runtime error in the Qt application we are building, were connecting a signal with a slot, but when running the app we got this error message in the console:
Object::connect: No such slot mgccis::web::SuperClassWebservice::onReadyRead() in ServiceInterface\SubClassWebservice.cpp:37

The connect code in the SubClassWebservice looked like this:

connect(httpPost_parameterData_.data(), SIGNAL(readyRead()), this, SLOT(onReadyRead()));

There was a slot in the subClassWebservice, took a google search session to find out the real problem, found this on Stackoverflow:
http://stackoverflow.com/questions/4322224/qt-slots-and-inheritance-why-is-my-program-trying-to-connect-to-the-parent-inst

I've forgot to add the Q_OBJECT in the class declaration of the sub class.

No comments: