Search code examples
pythonpyqtpyqt5qtimerqwebengineview

QWebEngineView: Timers do not function when visible


I was attempting to implement the code from this question, but I have discovered that QTimer does not fire under certain circumstances.

The simplified code:

app = QApplication([])

view = QWebEngineView()
view.show()

def callback():
    sys.exit(0)

QTimer.singleShot(1000, callback)

app.exec()

The application runs forever with this code (ie. callback is never executed). However, if you comment out view.show() then it exits after one second as it should.

As far as I can tell, this problem is particular to QWebEngineView; if we replace the QWebEngineView with a generic QWidget or QLabel, then it works as expected and exits after one second.

What is the cause of this, and how can I fix it?


Solution

  • As prompted by @eyllanesc, I have discovered that this is a bug introduced by the 5.14.0 release of the PyQtWebEngine module; the previous version (5.13.2) does not show this behavior.