Moustachauve
Moustachauve

Reputation: 191

How can I automatically detect a proxy?

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.

Upvotes: 8

Views: 4468

Answers (2)

Chris Browet
Chris Browet

Reputation: 4266

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]);

Upvotes: 2

Greg Hewgill
Greg Hewgill

Reputation: 992747

Since setUseSystemConfiguration is a static method, the following might do what you need:

QNetworkProxyFactory::setUseSystemConfiguration(true);

Upvotes: 11

Related Questions