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.
我有一个QTimer触发周期性事件。
QTimer
我不想直接停止计时器,因为我想将一些特殊信号同步到最后一个事件。
我可以通过设置它来实现这setSingleShot(true)一点,QTimer以便下一次拍摄将是单次拍摄,并且计时器在下一次拍摄后停止吗?
setSingleShot(true)
编辑: 它似乎工作。但setSingleShot(true)似乎不是原子的:我有时会在计时器停止之前观察到 2 次射击。
是的。是的你可以。事实上,“常规”计时器和单次计时器之间没有区别——除了这个标志。每次定时器超时,它都会检查单次标志。如果已设置,则计时器将自行注销,因此在您重新启动之前不会再次触发。