How to remove the mapper's item?
-
Hello, I used a QSignalMapper for used to lot of button clicked() event.
unfortunately, i can't find, how to remove the QSignalMapper's item.
So, I use QSignalMapper Iike this.
------------------------------------main.cpp------------------------------- // in main.cpp #define COUNT 7 QSignalMapper *mapper = new SignalMapper(); QList<QPushButton *> mButtons ; //setting for(int i =0; i < COUNT; i++) { QPushButton *pbtn = new QPushButton( ); mButtons.append(pbtn); connect(mButtons[i], SIGNAL(clicked()), mapper, SLOT(map())); mapper->setMapping(mButton[i], i); } RemoveMap(3); ----------------------------------------------------------------------------- void myclass::RemoveMap(int index) { // I want to know, how to remove mapper's item by index parameter. // I saw the removeMappings( ) function, but I couldn't guess the how to use it;.. } I need your help. thank you.
-
Hi,
Something like
mapper->removeMapping(myButton[i]);
-
@Eng.Jason
To add to @SGaist, you seem to be using one mapper with multiple buttons, which will not work. A signal mapper will map a single signal, from a single object.EDIT: Disregard this completely wrong comment.
-
@kshegunov Why will it not work ? AFAIK that's the goal of QSignalMapper: to map several objects to one signal with a parameter of known value.
-
@SGaist said:
Why will it not work ? AFAIK that's the goal of QSignalMapper: to map several objects to one signal with a parameter of known value.
I seem to have missed my morning coffee when I wrote that. Sure it will work.