How use different proxies for each QTwebview browser control in an application ?
-
Hello All,
I am developing an application that opens some sites on different-different QTwebview browser controls(for example 4 QTwebview browser).
Is it possible to use different proxy with each QTwebview browser ?
I am using below code to use proxy :-
@QNetworkProxy proxy;
proxy.setType(QNetworkProxy::HttpProxy);
proxy.setHostName(proxyName);
proxy.setPort(8080);
QNetworkProxy::setApplicationProxy(proxy);@Thanks in advance
Zain -
You can obtain the "QWebPage":http://qt-project.org/doc/qt-5.0/qtwebkit/qwebpage.html from your "QWebView":http://qt-project.org/doc/qt-5.0/qtwebkit/qwebview.html using method page() and then to change the network access manager of the "QWebPage":http://qt-project.org/doc/qt-5.0/qtwebkit/qwebpage.html using method "setNetworkAccessManager":http://qt-project.org/doc/qt-5.0/qtwebkit/qwebpage.html#setNetworkAccessManager. Please note the remark at the documentation:
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.
So it is a tricky and as you said you should try using separate QWebViews with separate QWebPages and separate "QNetworkAccessManagers":http://qt-project.org/doc/qt-5.0/qtnetwork/qnetworkaccessmanager.html
-
Hi,
Thanks for your answer, I am trying your suggestion and will let you know it is working or not.
Thanks again
Zain
-
[quote author="Zain" date="1357210708"]Thanks for your answer, I am trying your suggestion and will let you know it is working or not.
[/quote]OK, I forgot to note that you should call method "setProxy":http://qt-project.org/doc/qt-5.0/qtnetwork/qnetworkaccessmanager.html#setProxy to specify which proxy should your network access manager use.
-
Thanks for the tip.
Just for your information, here I am talking about more than 1 proxy at a time!!
Just wondering is it possible in QT ?
Thanks
Zain -
[quote author="Zain" date="1357212185"]Just for your information, here I am talking about more than 1 proxy at a time!!
[/quote]Yes, I understand you. As I noted in my previous post at the moment it is not possible to change the proxy after the QWebPage has already used it but you can try to use separate instances of QWebViews and QWebPages.
-
Hi leon.anavi,
Thank you very much for your help.
Now I am working in direction as you suggest.
Really appreciate your quick help.
Thanks
Zain :-) -
[quote author="Zain" date="1357213603"]
Thank you very much for your help.Now I am working in direction as you suggest.
Really appreciate your quick help.
[/quote]You are welcome. Good luck with the implementation and after that please share your experience and results :)
-
Hi
Now I want to run multiple webView in multiThreads
Thanks