[Qt-interest] Multiple signals to one slot

Neville Dastur qt at dastur.me.uk
Sun Jan 31 01:07:32 CET 2010


Thank you, but I needed the mapped int to still be passed. I suppose I 
could set a userdata for each checkbox to carry this, but after some 
futher reading I found that you can get the object from the mapped id. 
So I now do:

    QCheckBox *cb = qobject_cast<QCheckBox 
*>(m_signalMapperConceptFilters->mapping(i));

and I have my QCheckBox widget as well as the map int

Andreas Pakulat wrote:
> 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
>
>   



More information about the Qt-interest-old mailing list