Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[Solved]Q_OBJECT and vtable
When i put QObject in my H file I got this message
:/requestpost.cpp:4: undefined reference to `vtable for RequestPost'
class RequestPost:public QObject
void connection( QByteArray postData,const QString& url);
QIODevice *networkReply() const;
#endif // REQUESTPOST_H
I have done in a similar way a lots of times earlier and never got this problem.
Anyone who could tell me why this problem appers in this class declaration.
Asperamanca last edited by
I've never seen Q_OBJECT under comment.
Normally, you can resolve such issues by cleaning the project, then running qmake, and then rebuild.
If you want to be more specific, it should be enough to manually delete all generated files for that class - that is, the corresponding moc-File (if one even existed), and the corresponding object files, and then run qmake and build the project.
I comment the QObject so that the prj could work.
It,s very strange because I did an almost exactly class and it worked just fine.
bq. But I'll try your tip.
It worked now
miroslav last edited by
Since Q_OBJECT is commented out, qmake probably won't generate compile steps for the moc file. Uncomment it and run qmake again. If that does not fix it, poke again please.
It helped when I took the .o file away.
The comment was as I mentioned before just a lucky hit when I tried to get what went wrong when I builded my class.