How to manage proxies with QT QWebView

This is how I change the proxy:

QNetworkProxy proxy; proxy.setType(QNetworkProxy::HttpProxy); proxy.setHostName("ip"); proxy.setPort(8008); QNetworkProxy::setApplicationProxy(proxy); 

It works correctly if I do this before creating the WebView. But if I change the proxy during the life of QWebView, it just won’t load any site. What is the correct way to change proxy on the fly in QT?

Thanks.

+4
source share
1 answer

QWebPage :: setNetworkAccessManager method docs say that

Note. Changing the network access manager after using QWebPage is not currently supported. The results of this are undefined.

So, I assume that after installing the application proxy and after creating QWebPage, it will receive the QNetworkAccessManager and you will not be able to change its proxy settings.

As an alternative to using the application proxy, perhaps you can create a new QNetworkAccessManager and use its QNetworkAccessManager :: setProxy () method to configure the proxy server. Then submit this instance of QNetworkAccessManager to your web page.

In any case, you need to play with him. Hope this helps.

+5
source

All Articles