This is a local variable, not d->timer
:
QTimer *timer = new QTimer(this);
Yet, here you're checking if some d->timer
is active:
qDebug()<< "Count2" << d->timer->isActive();
And a line later you refer to timer
, not d->timer
again:
timer->stop();
Maybe you need to decide which timer you wish to use, and stick with it :)