1

Topic: Implementation QNetworkReply

It was required to transfer the answer received around qt - in QWebView as I understood, for this purpose it is necessary to palm off on it the implementation QNetworkReply with the come data. On Internet open spaces the example, Here it, or nearly so it is successfully found and used: #include <QNetworkReply> #include <QWebSecurityOrigin> #include <qcoreapplication.h> #include <QtCore/QMetaObject> class ProxyNetworkReply: public QNetworkReply {Q_OBJECT public: ProxyNetworkReply (QObject *parent, const QNetworkRequest &req, const QNetworkAccessManager:: Operation op): QNetworkReply (parent) {setRequest (req); setUrl (req.url ()); setOperation (op); setFinished (true); QNetworkReply:: open (QIODevice:: ReadOnly | QIODevice:: Unbuffered); QString string = "<! DOCTYPE HTML> <html> <head> </head> <body> <H1> description </H1> </body> </html>"; m_content = string.toUtf8 (); m_lOffset = 0; setHeader (QNetworkRequest:: ContentTypeHeader, QVariant ("text/html; charset=UTF-8 ")); setHeader (QNetworkRequest:: ContentLengthHeader, QVariant (m_content.size ())); QMetaObject:: invokeMethod (this,"metaDataChanged", Qt:: QueuedConnection); QMetaObject:: invokeMethod (this,"downloadProgress", Qt:: QueuedConnection, Q_ARG (qint64, m_content.size ()), Q_ARG (qint64, m_content.size ())); QMetaObject:: invokeMethod (this,"readyRead", Qt:: QueuedConnection); QMetaObject:: invokeMethod (this,"readChannelFinished", Qt:: QueuedConnection); QMetaObject:: invokeMethod (this,"finished", Qt:: QueuedConnection); QCoreApplication:: postEvent (this, new QEvent (QEvent:: NetworkReplyUpdated));} void abort () {QNetworkReply:: close ();} qint64 bytesAvailable () const {return m_content.size () - m_lOffset;} bool isSequential () const {return true;} qint64 size () const {return m_content.size ();} protected: qint64 readData (char* pData, qint64 lMaxSize) {if (m_lOffset> = m_content.size ()) return-1; qint64 lCount = qMin (lMaxSize, m_content.size () - m_lOffset); memcpy (pData, m_content.constData () + m_lOffset, lCount); m_lOffset + = lCount; return lCount;} private slots: private: QByteArray m_content; qint64 m_lOffset;} ; The example is successfully palmed off, causes signals, in particular "finished", is caused readData, as a result I see response ui on "finished" in the form of completed , but QWebView remains empty. In source codes implementation of this interface in qt, anything basic on signals did not note. The request to prompt to the beginner in QT, that lacks such minimum implementation QNetworkReply and how all the same to notify QWebView, what is possible  the answer?.................... QT - 5.5.1 + VS 2013 win7. Palmed off the answer redefinition QNetworkReply *ProxyNetworkManager:: createRequest (QNetworkAccessManager:: Operation op, const QNetworkRequest &req, QIODevice *outgoingData). Where class ProxyNetworkManager: public QNetworkAccessManager

2

Re: Implementation QNetworkReply

K> It was required to transfer the answer received around qt - in QWebView as I understood, for this purpose it is necessary to palm off on it the implementation QNetworkReply with the come data. K> on Internet open spaces the example, K> Here it, or nearly so it is successfully found and used: the Code using self-made reply could subscribe for its signals, only receiving object from createRequest therefore sending of signals removed from the designer, I send from a method of obtaining of the exterior data. All works.