Reputation: 21
Is it possible to start the Qtimer only once if the time is up
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)
Upvotes: 1
Views: 2012
Reputation: 31
Besides the signleShot method as eyllanesc mentioned, you can just stop the timer in self.function.
def function(self):
self.timer.stop()
Upvotes: 1
Reputation: 244282
To do this you must enable the singleShot
property:
self.timer = QtCore.QTimer()
self.timer.setSingleShot(True)
self.timer.setInterval(800)
self.timer.timeout.connect(self.function)
self.timer.start()
Or
QTimer.singleShot(800, self.function)
Upvotes: 3