QSignalMapper pretty good for this type of thing.
You would define your slot, for example:
public slots: void clicked(int buttonId);
Then add the QSignalMapper* member to your class and connect it to this slot:
signalMapper = new QSignalMapper(this); connect(signalMapper, SIGNAL(mapped(int)), this, SLOT(clicked(int)));
In addRadioToUI , after creating your button, do the following:
signalMapper.setMapping(one, button_cunter); // or trackId if that more practical
If you only need a pointer to the object that activated the signal, you can use the static function QOjbect::sender in your slot to get a handle to that.
source share