For change POST variables in qtwebkit need change or replace outgoingData in createRequest(...).
How to create own <PyQt4.QtCore.QIODevice object at 0x03BA...>
not QFile or QByteArray.
Exactly QIODevice object! It is needed for creation of writable device.
Or how to convert <PyQt4.QtCore.QBuffer object at 0x03BA...>
to <PyQt4.QtCore.QIODevice object at 0x03BA...>
.
This device most used in QNetworkAccessManager:
https://qt.gitorious.org/qt/webkit/source/7647fdaf9a4b526581e02fbd0e87c41a96cbfebb:src/network/access/qnetworkaccessmanager.cpp#L941
QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Operation op,
const QNetworkRequest &req,
QIODevice *outgoingData)
...
UPDATE: After call this method:
def createRequest(manager, operation, request, data):
if data.size() > 0:
post_body = "q=hello"
output = QtCore.QByteArray()
buffer = QtCore.QBuffer(output)
buffer.open(QtCore.QIODevice.ReadWrite)
buffer.writeData(post_body)
data = buffer
reply = QNetworkAccessManager.createRequest(manager, operation, request, data)
return reply
script hangs up...
If I'm making sense of your question, A
QBuffer
is already an implementation of the (abstract, as noted by @mdurant)QIODevice
class. So for example (I tried this on PySide but I believe PyQt should be the same):To create a writable
QIODevice
writing into aQByteArray
, you can do more or less the following:You can now write to
buff
as if it was aQIODevice
and then the data will be available inba
.Basically you were close, I wonder why you didn't get a segmentation fault, it happened to me every time when I didn't set the parent object of the new data object:
I wrote about this exact issue here: https://github.com/integricho/path-of-a-pyqter/tree/master/qttut07