[Qt-interest] Multiple signals to one slot
Andreas Pakulat
apaku at gmx.de
Sat Jan 30 21:33:18 CET 2010
On 30.01.10 20:09:41, Neville Dastur wrote:
> Hi
>
> I have a group of checkboxes. Using the QSignalMapper I "connect" all of
> them to a single member function
>
> connect(ui->checkBoxDescriptionStatus_Current,
> SIGNAL(stateChanged(int)),
> m_signalMapperDescriptionFilters,
> SLOT(map()));
> connect(ui->checkBoxDescriptionStatus_Retired,
> SIGNAL(stateChanged(int)),
> m_signalMapperDescriptionFilters,
> SLOT(map()));
>
> etc ...
>
> I use the setMapper to specify a int for each checkbox
>
> m_signalMapperDescriptionFilters->setMapping(ui->checkBoxDescriptionStatus_Current,
> NBD::ND_SNOMED_DESCRIPTIONSTATUS_Current);
> m_signalMapperDescriptionFilters->setMapping(ui->checkBoxDescriptionStatus_Retired,
>
> NBD::ND_SNOMED_DESCRIPTIONSTATUS_Retired);
>
> and finally connect the whole thing together with:
> connect(m_signalMapperDescriptionFilters,
> SIGNAL(mapped(int)),
> this,
> SLOT(map_DescriptionStatusFilterChange(int)));
>
> My problem now is how do a get the actual state of the checkbox that
> fired the signal?
Either store a map of int->QCheckBox, or use the QWidget* version of
setMapping to transport the checkbox, then you can simply cast it in the
slot.
Andreas
--
In the stairway of life, you'd best take the elevator.
More information about the Qt-interest-old
mailing list