passing object names to slot implementation

Matthias Hoelzer-Kluepfel Matthias at Hoelzer-Kluepfel.de
Mon Jul 29 07:57:02 UTC 2002


On Monday 29 July 2002 00:28, Berndt Josef Wulf wrote:
> G'day,
>
> I'm writing an application (HAM Radio Controller) containing +60 buttons
> for which I implemented one slot common to all of them -
>  slotButtonClick().
>
> The problem now is to identify which button was calling the slot
> function, an easy task in Delphi. Is there a mechanism that allows an
> identification of the sender object (e.g. the name of the
> object/button)?
>
> Once the sender is know, a simple `switch' statement is all that is
> needed in implementing the respond code, reducing overall code size.
>
> Any help is very much appreciated.

Hi,

you can either use "sender()" in the slot to get the object that emitted the 
signal, which is the dirty approach, or you can use the QSignalMapper map 
each button to an id.

Bye,
Matthias.





More information about the KDevelop-devel mailing list