May 2019
Intermediate to advanced
542 pages
13h 37m
English
Sometimes in an application, we need to repeat an action at specified intervals, such as autosaving a document, polling a network socket, or nagging a user incessantly to give the application a 5-star review in the app store (well, maybe not that one).
QTimer can handle this too, as you can see from the following code block:
interval_seconds = 10 self.timer = qtc.QTimer() self.timer.setInterval(interval_seconds * 1000) self.interval_dialog = AutoCloseDialog( self, "It's time again", f"It has been {interval_seconds} seconds " "since this dialog was last shown.", 2000) self.timer.timeout.connect(self.interval_dialog.show) self.timer.start()
In this example, we're creating a QTimer object explicitly rather than using the static ...
Read now
Unlock full access