Вопрос

I have a customized QNetworkAccessManager and a QWebPage class, now I want to read the reply data of each request retrieved by the QWebPage.

Now I connected the finished() signal, but since QWebPage connected it first, and the first finished() slot of QWebPage would read all the data from the QNetworkReply object, thus the slot in QNetworkAccessManager would read nothing at all.

So can I "insert" a connection to the list of QObject's connections, instead of appending it?

Это было полезно?

Решение

The problem is that if you were able to do that, the QWebPage wouldn't be able to read the data from the QNetworkReply object, because the reply is a sequential QIODevice and the data can only be read once.

The only way I've been able to deal with this is to override QNetworkAccessManager::createRequest and have it return a QNetworkReply subclass which acts as a a wrapper around the actual reply object, which can capture the incoming data.

Ah, see How to read data from QNetworkReply being used by QWebPage? for a solution.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top