原文:QObject::startTimer: QTimer can only be used with threads started with QThread

解决: 我的原因main函数之中没有QCoreApplication::exec 函数的执行,这样我的定时器启动后main函数就退出了 如果是正常Qt cretor创建的工程,main函数中会有return a.exec ,而这会让程序进程不结束,也就是可以接收到timer的timeout信号了。 ...

2020-03-18 14:14 0 1578 推荐指数:

查看详情

Qt: QTimerQThread

QTimer 跑在其他线程. 一般写法如下. 1. 在main thread中为worker thread指定定时器. QThread* thread = new QThread(this); thread->start(); QTimer *timer = new ...

Mon Jan 12 19:48:00 CST 2015 0 10680
QTimerQThread环境中失效的问题

QTimer在非QThread的环境下能正常工作。但在QThread环境下,需要做一些改动才能正常工作。 创建Qt的线程有两种方式: 1. 子例化QThread 可以在虚函数run中启动定时器,大致的代码如下: 两处指针new的时候不能加this指针,run函数中必须加 ...

Sat May 26 19:07:00 CST 2018 0 2062
 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM