May 2019
Intermediate to advanced
542 pages
13h 37m
English
Assuming we're in the __init__() method of a class, it looks like this:
self.timer = qtc.QTimer() self.timer.setInterval(10000) self.timer.timeout.connect(self.every_ten_seconds)
timer = qtc.QTimer() timer.setSingleShot(True) timer.setInterval(1000) timer.start() while timer.remainingTime(): sleep(.01) run_delayed_command()
QTimer is being used synchronously with the while loop. This creates blocking code. The same can be done asynchronously, like so:
qtc.QTimer.singleShot(1000, run_delayed_command)
Read now
Unlock full access