首页| 论坛| 消息
主题:Qt的多线程是不是不能使用QTimer
回帖:up_timer = new QTimer;
up_timer->setInterval(1000);
up_timer->start();
up_timer->moveToThread(&up_img_Thread);//定时器移到子线程中
connect(up_timer, SIGNAL(timeout()), this, SLOT(up_model_file()), Qt::DirectConnection);
connect(this, SIGNAL(stop_up_timer()), up_timer, SLOT(stop()));
connect(this,SIGNAL(start_up_timer()),up_timer,SLOT(start()));
up_img_Thread.start();
这样写 定时器的槽函数就是在子线程中执行的
下一楼›:巫添良:    up_timer = new QTimer;
    up_timer ..
‹上一楼:继承的不要带this,直接qtimer(),并且实例化的k也只能在run里面使用或者信号控制

查看全部回帖(34)
«返回主帖