[Qt-interest] How to find out which SIGNAL was sent

Colin S. Miller no-spam-thank-you at csmiller.demon.co.uk
Thu Nov 18 21:43:35 CET 2010


NoRulez wrote:
> Hello,
> 
>  
> 
> how can I find out which signal was sent from a specific widget/QObject?
> 
> For example:
> 
>  
> 
> connect (myWidget1, SIGNAL(sig1()), this, SLOT(doSomething()));
> 
> connect (myWidget1, SIGNAL(sig2()), this, SLOT(doSomething()));
> 
> connect (myWidget2, SIGNAL(sig1()), this, SLOT(doSomething()));
> 
> connect (myWidget2, SIGNAL(sig2()), this, SLOT(doSomething()));
> 


enum SignalCode
{
    SignalCode_1,
    SignalCode_2,
}


MyWidget::doSomething(SignalCode sigCode);

MyWidget::doSomething1() {doSomething(SignalCode_1);}
MyWidget::doSomething2() {doSomething(SignalCode_2);}


connect (myWidget1, SIGNAL(sig1()), this, SLOT(doSomething1()));
connect (myWidget1, SIGNAL(sig2()), this, SLOT(doSomething2()));
connect (myWidget2, SIGNAL(sig1()), this, SLOT(doSomething1()));
connect (myWidget2, SIGNAL(sig2()), this, SLOT(doSomething2()));


HTH,
Colin S. Miller



More information about the Qt-interest-old mailing list