[PyQt] Bug in QWebEngineDownloadItem

Kovid Goyal kovid at kovidgoyal.net
Sun Sep 13 09:01:59 BST 2015


It appears to be impossible to connect to the stateChanged() signal of
QWebEngineDownloadItem. Run the following test script as:

python3 test.py /path/to/some/binary/file

This gives the error
QObject::connect: No such signal QWebEngineDownloadItem::stateChanged(QWebEngineDownloadItem::DownloadState)
Traceback (most recent call last):
  File "/t/test.py", line 9, in download_requested
    item.stateChanged.connect(print)
TypeError: connect() failed between stateChanged(QWebEngineDownloadItem::DownloadState) and unislot()

#!/usr/bin/env python3
# vim:fileencoding=utf-8

import sys
from PyQt5.Qt import *


def download_requested(item):
    item.stateChanged.connect(print)

app = QApplication([])
w = QWebEngineView()
w.page().profile().downloadRequested.connect(download_requested)
w.load(QUrl.fromLocalFile(sys.argv[-1]))
w.show()
app.exec_()

It may be that the bug is actually in Qt in view of
QObject::connect: No such signal QWebEngineDownloadItem::stateChanged(QWebEngineDownloadItem::DownloadState)
but looking at the Qt source code, that signal does appear to be defined.

Kovid.

-- 
_____________________________________

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre-ebook.com
_____________________________________


More information about the PyQt mailing list