I have started Timer to wait for certain condition to be true. IF condition is true then I stop timer and dont want timeout signal to emit or execute connnected slot. But if condition is false within specified time then its allright to emit signal timeout(). But whatever is the case it always emit timeout signal. I have used blockSignals ( true ) as well and it doesnt work. Can some one please advice me.
void timerStart( QTimer* timer, int timeMillisecond )
{
timer = new QTimer( this );
timer->setInterval( timeMillisecond );
timer->setSingleShot( true );
connect( timer, SIGNAL( timeout() ), this, SLOT( noRespFrmServer( ) ) ) ;
//timer->start( timeMillisecond );
timer->start();
}
void timerStop( QTimer* timer )
{
connect( timer, SIGNAL( destroyed( timer ) ), this, SLOT( stopTimerbeforeTimeout( ) ) );
qDebug() << " we are in timer stop";
if( timer )
{
timer->stop();
timer->blockSignals( true );
delete timer;
}
}
Also in timerStop function I have tried to emit destroyed signal but I got response that it fails to connect. pLease advice me.
timerStart()
you ignore the passed parametertimer
, and don't store your newly created timer, so you have no way to stop it. Where do you get the timer you pass totimerStop()
? Did you perhaps mean to passQTimer*&
totimerStart()
, or to store the timer in a member or (ugh) global? – Toby Speight