Phil Hannent
Phil Hannent

Reputation: 12327

How do I get the system proxy using Qt?

I have the following code that I am trying to extract the systems proxy settings from:

QList<QNetworkProxy> listOfProxies = QNetworkProxyFactory::systemProxyForQuery();
foreach ( QNetworkProxy loopItem, listOfProxies ) {
    qDebug() << "proxyUsed:" << loopItem.hostName();
}

I only get one item back and with a blank host name. Any ideas what I am missing?

Upvotes: 2

Views: 7949

Answers (2)

Salil
Salil

Reputation: 11

QNetworkProxyQuery npq(QUrl(QLatin1String("http://www.google.com")));

Don't forget to use QLatin1String :)

Upvotes: 1

Phil Hannent
Phil Hannent

Reputation: 12327

By putting:

QNetworkProxyQuery npq(QUrl("http://www.google.com"));
QList<QNetworkProxy> listOfProxies = QNetworkProxyFactory::systemProxyForQuery(npq);

I appear get the proxy out.

Upvotes: 6

Related Questions