我正在尝试使用 QTimer 并且我开始良好,但是当我尝试通过使用 isActive 检查其状态来停止它时,它总是返回 false,但计时器插槽内的代码正在以正确的时间间隔执行。
这是代码
void CurrentController::currentAction(void)
{
count++;
QTimer *timer = new QTimer(this);
if(count == 1)
{
qDebug()<< "Count" << count;
QObject::connect(timer, SIGNAL(timeout()), this, SLOT(callMethod()));
timer->setInterval(10000);
timer->start();
}
用于停止计时器
if(count >= 2)
{
qDebug()<< "Count2" <<timer->isActive();
timer->stop();
count = 0;
}
}
帮助感谢感谢...