c++ - How to map to overload Qt slot -


i want overload qt slot either react emitted clicked() signal qpushbutton or statechanged(int) signal qcheckbox (since there no signal emits when checkbox checked only).

so these 2 slots.

void widget::sendcom(qstring data) {     std::cout << "in scope of sendcom"<< std::endl; } void widget::sendcom(qstring data, int state) {     std::cout << "in scope of overloaded sendcom: " << std::endl; } 

with widget->createbutton(slot(sendcom(qstring), data); call following , mapping works fine.

void widget::createbutton(const char *member, qstring &data) {     qpushbutton *button = new qpushbutton(this);     signalmapper = new qsignalmapper(this);     signalmapper->setmapping(button, data);     connect(signalmapper, signal(mapped(qstring)), this, member);     connect(button, signal(clicked()), signalmapper, slot(map()));     ... }   void widget::createcheckbox(const char *member, qstring &data) { } 

with widget->createcheckbox(slot(qstring, int), data) want pass in chechbox's state overloaded widget::sendcom(qstring data, int state)as well. how has mapping done?

according documentation qsignalmapper manages parameterless signals. derive new class qcheckbox connect statechanged(int) signal corresponding slot in class emit setchecked() or setunchecked() signal can handled qsignalmapper.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -