For one of my projects, I made a QWebView. Everything is working fine, but when I use it at school, I get an error because the proxy is not defined. How would I make it possible to auto detect the proxy, like in Firefox and IE?
I've found this in QNetworkProxyFactory
:
setUseSystemConfiguration(bool enable)
But I can't find how to use it.
Select the proxy you want to configure, then enter the settings on the right. Configure proxy server settings automatically: Select Auto Proxy Discovery. Use a proxy auto-configuration (PAC) file: Select Automatic Proxy Configuration, then enter the address of the PAC file in the URL field.
Since setUseSystemConfiguration
is a static method, the following might do what you need:
QNetworkProxyFactory::setUseSystemConfiguration(true);
Here is a working example of using the system defined proxy:
QNetworkProxyQuery npq(QUrl("http://www.google.com"));
QList<QNetworkProxy> listOfProxies = QNetworkProxyFactory::systemProxyForQuery(npq);
if (listOfProxies.size())
QNetworkProxy::setApplicationProxy(listOfProxies[0]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With