c++ - Undefined reference to SOME_SIGNAL_NAME -



c++ - Undefined reference to SOME_SIGNAL_NAME -

this question has reply here:

qt connecting signal , slot in object fellow member of mainwindow 2 answers

i have signal in class, called requestfinished. have slot _finished, should activate signal. have error undefined reference my_signal. here _finished:

void vk::_finished(qnetworkreply *reply) { if (reply->error() != qnetworkreply::noerror) { qdebug() << (qstring) reply->readall(); } else { qstring json(reply->readall()); vkresponse *response = new vkresponse(json); vkerror *error = new vkerror(json); vkanswer *answer = new vkanswer(error, response); emit requestfinished(answer); } }

here class vk:

class vk { public: vk(qstring token); void request(qstring method, std::map<qstring, qstring> data); ~vk(); private: qstring token; private slots: void _finished(qnetworkreply *reply); signals: void requestfinished(vkanswer *answer); };

as can see, contains method requestfinished in signals. problem? thanks.

your vk class needs publicly inherit qobject , include q_object first thing:

class vk: public qobject { q_object public: vk(qstring token); void request(qstring method, std::map<qstring, qstring> data); virtual ~vk(); private: qstring token; private slots: void _finished(qnetworkreply *reply); signals: void requestfinished(vkanswer *answer); };

you need ensure moc run against (usually automatic in qtcreator)

c++ qt signals slots

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -