[Qt-interest] Howto: multiple emissions of signal cause one single slot execution.

william.crocker at analog.com william.crocker at analog.com
Fri Jun 11 14:20:38 CEST 2010


>>
>> Now the question: How would you execute "raiseHand()" only once in such a 
>> scenario? (In other words: You don't want to raise the hand on every single 
>> yell, but as a confirmation on all the yells, given a certain happening.)
>>

void
MyApp::raiseHand() {
     if( ! m_RaisHandScheduled ) {
         QTimer::singleShot(0, this, SLOT(doRealRaiseHand()));
         m_RaiseHandScheduled = true;
     }
}

void
MyApp::doRealRaiseHand() {
     ... really raise my hand ...
     m_RaiseHandScheduled = false;
}



More information about the Qt-interest-old mailing list