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

Thiago Macieira thiago.macieira at trolltech.com
Mon Jun 22 16:19:16 CEST 2009


Ed Sutton wrote:
>> >>>> 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
>>
>> Don't your QRadioButtons have labels or icons that indicate the new
>> channel? You should be able to retrieve those from the pointer
>> returned by sender() and associate the label or icon with your data
>> object.
>
>I made an STL map that use the widget text name as the key to retrieve
> my QWidgetTagPair class (QRadioButton* +  MyObject* ).
>
>It is more work than I was used to as Microsoft widgets have a Tag
> object property that you use to associate with your data object.  As a
> lazy programmer I wanted to make sure I had not missed a similar
> existing approach in QT.  Thank you for your help.

QObjects have an "objectName" property that you can set to any string that 
you want. It doesn't have to be a human-readable text.
-- 
Thiago Macieira - thiago.macieira (AT) nokia.com
  Senior Product Manager - Nokia, Qt Software
      Sandakerveien 116, NO-0402 Oslo, Norway
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090622/b328900e/attachment.bin 


More information about the Qt-interest-old mailing list