I checked other similar questions and tried their solutions but they don\'t work for me.
I\'m basically trying to make a http client that only makes post requests. I
I share another possible problem here as this post is the top most in google search.
In addition to add Q_OBJECT, you must also add public slots: or public Q_SLOTS: for your customized event. Otherwise, you'll still encounter the QObject::connect: No such slot error.
I give a brief summary here according to Zeta's post and the other post
To solve “No such slot” error, you must check..
- Check if your class inherits
QObjector any derived class from QObject- Append
Q_OBJECTmacro inside the class definition- Append
slotsorQ_SLOTSafter your private/protected/public keyword for your event- If you do check 1-3, then clean, run qmake, and rebuild again to make sure all your things in 1-3 are generated by moc.
Finally, a example here:
class MyClass: public QObject { //check 1
Q_OBJECT //check 2
public slots: //check 3
void onEvent(int);
};
Hope this saves others' life