PDA

View Full Version : Set a proxy for QWebView



andzoff
11th May 2011, 11:28
hi everibody,

I'm dealing with a simple browser application, like the one in FancyBrowser example in the normal webkit package. Used classes are QWebView and QWebPage.
My problem is that I must use a proxy for the internet connection. How can I set a proxy (hostname, port, ...) in my application? Any examples?

Thank you in advance.

wysota
11th May 2011, 12:53
See QNetworkProxy::setApplicationProxy() or QWebPage::networkAccessManager() and QNetworkAccessManager::setProxy().

andzoff
13th May 2011, 14:20
OK, it works,
Thank you.

Here the code I used:

QNetworkProxy proxy;
proxy.setType(QNetworkProxy::Socks5Proxy);
proxy.setType(QNetworkProxy::HttpProxy);
proxy.setHostName("proxy.example.com");
proxy.setPort(1080);
// proxy.setUser("username");
// proxy.setPassword("password");
QNetworkProxy::setApplicationProxy(proxy);

Andrea

Added after 6 minutes:

Hi wysota,
thank again for your help.

Now I've got a more complicate challenge.

In my company there's a proxy for the web navigation. For internet sites I must use the proxy, but for the internal web servers (like http://192.168.13.49) I must not use the proxy.
In firefox and other commercial browsers, I can del with the proxy exceptions. In the connection settings panel I can set a proxy address and some exceptional addresses for which the proxy shall not be used.

Do you think is possible to do such thing with my Qt browser?
Thank you again from Italy.

wysota
13th May 2011, 14:25
QNetworkProxyFactory