简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM