With Qt 4.8 I create a number of input widgets (QSpinBox, QSlider) programmatically. In the end, I would like to have a single method to handle changes of any of these input widgets, ideally by index.
However, these widgets only have a Signal with parameter, e.g. valueChanged(int)
.
This is not compatible with QSignalMapper()'s Slot map()
.
As it was pointed out in the comments, the connection does work!
connect( spinbox, SIGNAL( valueChanged(int) ),
signalMapper, SLOT( map() )
);
Now I just need to get the value, but this cannot be done via the sender() method anymore, because this now is the SignalMapper.
Original question:
Is there another way besides (re)implementing QSignalMapper
with additional parameters or a parameter-less valueChanged()
for the widget or using objectName
and QObject::sender()
in order for the Slot to see which element changed (and get the new value)?