May 2019
Intermediate to advanced
542 pages
13h 37m
English
QTimer is a simple QObject subclass that can emit a timeout signal after a certain period of time.
The simplest way to defer a single action with QTimer is to use the QTimer.singleShot() static method, as follows:
def show(self): super().show() qtc.QTimer.singleShot(self.timeout * 1000, self.hide)
singleShot() takes two arguments: an interval in milliseconds and a callback function. In this case, we're calling the self.hide() method after a number of self.timeout seconds (we will multiply by 1,000 to convert this into milliseconds).
Running this script again, you should now see your dialog behaving as expected.
Read now
Unlock full access