[Qt-interest] Multiple SIGNAL connected to single SLOT and sender() function

Josiah Bryan jbryan at productiveconcepts.com
Tue Nov 10 16:47:12 CET 2009


Sambhav wrote:
> Hi,
>  
> I want to connect multiple QPushButton(s) to a single SLOT. In the SLOT 
> it is required to change the certain properties of the Button. I checked 
> the documentation and found this under signal and slots page.
>  
> *Advanced Signals and Slots Usage*
> For cases where you may require information on the sender of the signal, 
> Qt provides the QObject::sender 
> <https://mail.google.com/mail/html/compose/static_files/qobject.html#sender>() 
> function, which returns a pointer to the object that sent the signal.
>  
> I want to know how to convert the QObject returned by the sender 
> function to the QPushButton object.

QPushButton *btn = dynamic_cast<QPushButton*>(sender());
if(btn)
    // do something with your push button

>  
> Thanks and Regards,
> Sambhav
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest

-- 

-=-=-=-=-=-=-=-=-=-=-=-=-
Josiah Bryan
Productive Concepts, Inc.
jbryan at pciint.com
(765) 964-6009, ext. 224




More information about the Qt-interest-old mailing list