qt - QML C++ Signals-Slot not overloaded -
i have spent whole day on code , couldn't figure out problem.
this error:
* iso c++ forbids declaration of 'cppreturnanswer' no type [-fpermissive] * 'int handletextfield::cppreturnanswer(qvariant)' cannot overloaded * 'void handletextfield::cppreturnanswer(qvariant)'
and code:
//handletextfield.h class handletextfield : public qobject { q_object public: signals: void cppreturnanswer(qvariant data); // error here public slots: std::string text; qstring color = qstring::fromstdstring(text); emit cppreturnanswer(qvariant(color)); // error here };
which used respectively in program
// in .. handletextfield.cpp ... void handletextfield::handlesubmittextfield(const qstring &in) { qdebug() << "c++: handletextfield::handlesubmittextfield:" << in; text="green"; qstring color = qstring::fromstdstring(text); emit cppreturnanswer(qvariant(color)); } // in main.cpp ... qobject *toplevel = engine.rootobjects().at(0); qquickwindow *window = qobject_cast<qquickwindow *>(toplevel); // connect - qml c++ ---- works nice qobject::connect(window, signal(submittextfield(qstring)), &handletextfield, slot(handlesubmittextfield(qstring))); // connect - c++ qml ---- not working qobject::connect(&handletextfield, signal(cppreturnanswer(qvariant)), window, slot(qmlupdatedata(qvariant))); // in main.qml ... function qmlupdatedata(text){ // hack(msg designer:: imperative code not supported in qt quick) page.color=text // gotdata c++ backend }
any suggestions , comments highly appreciated.
Comments
Post a Comment