主题 : QTimer的singleShot的问题 复制链接 | 浏览器收藏 | 打印
级别: 新手上路
UID: 82746
精华: 0
发帖: 33
金钱: 165 两
威望: 33 点
综合积分: 66 分
注册时间: 2012-11-27
最后登录: 2017-09-13
楼主  发表于: 2013-09-16 10:16

 QTimer的singleShot的问题

我写了一个函数大概是
func1()
{
timer1 =  new QTimer(this);
timer1->singleShot(1000,this,SLOT(func2()));
timer1->stop();
}

func2()
{
timer2 =  new QTimer(this);
timer2->singleShot(1000,this,SLOT(func3()));
timer2->stop();
}

func3()
{
timer3 =  new QTimer(this);
timer3->singleShot(1000,this,SLOT(func3()));
timer3->stop();
}

代码使得func1运行超时1s后会触发func2,func2超时后接着触发func3,func3再触发func1,形成一个循环,我想要比如说让func1停止执行后,程序就终止,func2和func3都不再执行,希望各位能帮忙解决一下,谢谢啦!