[SOLVED] Can we set specific Network proxy for QWebView
-
I am having one application where I am creating multiple QWebView objects.
Since each QWebView object is loading different URL , and my network admin wanted to route the specific url through some proxy.
I have one function QNetworkProxy::setApplicationProxy(), which will set the proxy for the entire app, i.e. all QWebView will use that proxy , but I wanted to use different proxy for different QWebView.Please advice how can we achieve this.
Please help it is very urgent!!!!! -
I think that the official "Qt documentation offers a solution for your request":http://qt-project.org/doc/qt-4.8/qnetworkproxy.html#details:
bq. An alternative to setting an application wide proxy is to specify the proxy for individual sockets using QAbstractSocket::setProxy() and QTcpServer::setProxy(). In this way, it is possible to disable the use of a proxy for specific sockets using the following code:
@ serverSocket->setProxy(QNetworkProxy::NoProxy);@ -
Thanks for your suggestion , but I am not using any QTCPSocket/QAbstractSocket/QTcpServer at all.
I am just using QWebview to load my url. and we can't call this function(setProxy) on QWebView.so probably this is not the way to achieve this.
Please share if you have any other thought -
Have you seen "this thread at stackoverflow":http://stackoverflow.com/questions/6072574/how-do-i-manage-proxies-with-qt-qwebview?
It highlights the documentation about "QWebPage":https://qt-project.org/doc/qt-4.8/qwebpage.html and method "setNetworkAccessManager":https://qt-project.org/doc/qt-4.8/qwebpage.html#setNetworkAccessManager:
bq. Note: It is currently not supported to change the network access manager after the QWebPage has used it. The results of doing this are undefined.
The recommended solution at "stackoverflow.com":http://stackoverflow.com/questions/6072574/how-do-i-manage-proxies-with-qt-qwebview to create QNetworkAccessManager, set up a proxy and then to pass it to the web page seems reasonable.
-
Thanks a lot leon!!!!!!!!!!!!
You made my life really cool.
I am being able to set the different proxy for different Qwebview inside a single application.
your solution simply rockzz!!!!!!!! -
[quote author="Ashish Mittal" date="1332916135"]Thanks a lot leon!!!!!!!!!!!!
You made my life really cool.
I am being able to set the different proxy for different Qwebview inside a single application.
your solution simply rockzz!!!!!!!!
[/quote]You are welcome :) I am glad that the issue was solved but please note that I got the idea from a thread at "stackoverflow.com":http://stackoverflow.com/questions/6072574/how-do-i-manage-proxies-with-qt-qwebview.