How can we restrict QWebView not to download some js and css files.
-
Hi,
You can do it in following way:
- Create custom QNetworkAccessManager class by subclassing it.
- Re-implement createRequest in it. It will be called everytime a new request is done by QWebview.
Something like this:
QNetworkReply *MyQNAM::createRequest ( Operation op, const QNetworkRequest & req, QIODevice * outgoingData){ QNetworkReply *reply = QNetworkAccessManager::createRequest(op, req, outgoingData); qDebug() << req.url(); return reply; }
- Get the current URL from QNetworkRequest req. You can filter according to it.
- Finally set this custom QNetworkAccessManager to QWebView's page() using setNetworkAccessManager.
Hope this helps...