[Qt-interest] connect()ing multiple buttons to a receiver

Malyushytsky, Alex alex at wai.com
Wed Jan 7 22:51:42 CET 2009


You have 2 choices

1) QObject * QObject::sender () const   [protected]

Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. The pointer is valid only during the execution of the slot that calls this function.
The pointer returned by this function becomes invalid if the sender is destroyed, or if the slot is disconnected from the sender's signal.

2)QSignalMapper.

Best regards,
 Alex


-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Paul England
Sent: Tuesday, January 06, 2009 8:55 PM
To: qt-interest at trolltech.com
Subject: [Qt-interest] connect()ing multiple buttons to a receiver

To put this simply:

I will have a few buttons (4 or 5) that I want to connect() to a single
receiver.
The receiver will behave slightly differently depending on what button
is pushed though (does the same thing on different data).

The buttons are stored in an array, and are made in a loop.  How many
depends on an
environment variable.  I can connect() them to the receiver just fine,
but as they are in
an array, the receiver doesn't know which one was pushed.

 From what I remember, reimplementing event handlers is a nono.

Cheers
Paul
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest


---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.

"This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you."

"Please consider our environment before printing this email."




More information about the Qt-interest-old mailing list