原文: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