[PyQt] TypeError: setRawHeader(self, Union[QByteArray, bytes, bytearray], Union[QByteArray, bytes, bytearray]): argument 1 has unexpected type 'str'

redstone-cold redstone-cold at 163.com
Sun May 15 10:58:24 BST 2016


For

void QNetworkRequest::setRawHeader(const QByteArray &headerName, constQByteArray &headerValue)
(1)
with PyQt4 , 
request = QNetworkRequest(QUrl(url))
userAgent = 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36'
request.setRawHeader('user-agent',userAgent)


works well


while with PyQt5.6, just report error 
TypeError: setRawHeader(self, Union[QByteArray, bytes, bytearray], Union[QByteArray, bytes, bytearray]): argument 1 has unexpected type 'str'


(2)
The code in doc http://doc.qt.io/qt-5/qnetworkrequest.html#setAttribute
request.setRawHeader(QByteArray("Last-Modified"),QByteArray("Sun, 06 Nov 1994 08:49:37 GMT"));
just report 
TypeError: arguments did not match any overloaded call:
  QByteArray(): too many arguments
  QByteArray(int, str): argument 1 has unexpected type 'str'
  QByteArray(Union[QByteArray, bytes, bytearray]): argument 1 has unexpected type 'str'


Any ideas for these problems ?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20160515/1f9450d1/attachment.html>


More information about the PyQt mailing list