如果时间到了,是否仅可以启动Qtimer一次
self.timer = QtCore.QTimer()
self.timer.setInterval(10000)
self.timer.start(800) # start only once, not every 800 milliseconds
self.timer.timeout.connect(self.function)
为此,您必须启用singleShot
属性:
singleShot
或
self.timer = QtCore.QTimer()
self.timer.setSingleShot(True)
self.timer.setInterval(800)
self.timer.timeout.connect(self.function)
self.timer.start()
除了eyllanesc提到的signleShot方法之外,您可以通过self.function停止计时器。
QTimer.singleShot(800, self.function)