Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要每秒通过 Upd 套接字发送我的 Qt 应用程序的状态。我怎样才能做到这一点?我应该使用 QThread::sleep 子类 QThread e 还是有最好的方法?谢谢
最后我使用了不同的方法:
一个QTimer:
QTimer
QTimer iAmAliveTimer.setInterval(1500); iAmAliveTimer.setSingleShot(true); connect(&iAmAliveTimer, SIGNAL(timeout()), this, SLOT(sendIamAlive()), Qt::UniqueConnection); iAmAliveTimer.start();
当SLOT被调用时,我通过我的套接字发送我需要的东西。
SLOT