[Qt-interest] How associate slot sender with my data object?

Thomas Dähling t.daehling at googlemail.com
Sat Jun 20 20:20:47 CEST 2009


In your initial mail you asked whether it's possible to know the sender's  
checked state from within a slot. Well, QObject::sender() tells you the  
QObject that emitted the signal, so you could qobject_cast<> that to a  
QRadioButton and check its state, and do whatever else you want to know  
about the sender.

But I might as well be misunderstanding your use-case right here :-)

/Thomas

Am 20.06.2009, 18:14 Uhr, schrieb Ed Sutton <ESutton at fescorp.com>:

> Thank you for your help.  ( I apologize for accidentally replying  
> directly )
>
>> I take it you are looking for QObject::sender()
>> (http://doc.trolltech.com/4.5/qobject.html#sender) ?
>
> I am not sure I understand.
>
> I can get the sender if I use the SLOT(channelChanged(QWidget*))  
> signature.  How can QObject::sender() be used to associated the sender  
> with my data object?
>
> Forgive for being slow.
>
> -Ed
>
>> > I am getting started using signals and slots. I use QSignalMapper with
>> > QGroupBox collection of QRadioButtons that select video channels.
>> >
>> > In the received slot, how can I both retrieve the sender's checked  
>> state
>> > and associate the sender with it's related channel data object?  Do QT
>> > widgets support a pointer to a void* "tag object"?  Some way to
>> > associate my data object with the signal sender?  I tried to make my  
>> own
>> > but cannot seem to derive from QRadioButton.
>> >
>> > In order to determine the QRadioButton checked state in the slot, the
>> > best choice seems to use the SLOT(channelChanged(QWidget*)) signature.
>> > In order to associate the sender with my data object, must I make my  
>> own
>> > associative map collection?  Is this typical or is there a better
>> > approach?
>> >
>> > Thanks in advance for sharing your experience,
>> >
>> > -Ed
>> >
>> > _______________________________________________
>> > Qt-interest mailing list
>> > Qt-interest at trolltech.com
>> > http://lists.trolltech.com/mailman/listinfo/qt-interest
>>
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest





More information about the Qt-interest-old mailing list