QNetworkProxyFactory Class

The QNetworkProxyFactory class provides fine-grained proxy selection. More...

Header: #include <QNetworkProxyFactory>
qmake: QT += network
Since: Qt 4.5

Public Functions

QNetworkProxyFactory()
virtual ~QNetworkProxyFactory()
virtual QList<QNetworkProxy> queryProxy(const QNetworkProxyQuery &query = QNetworkProxyQuery()) = 0

Static Public Members

QList<QNetworkProxy> proxyForQuery(const QNetworkProxyQuery &query)
void setApplicationProxyFactory(QNetworkProxyFactory *factory)
void setUseSystemConfiguration(bool enable)
QList<QNetworkProxy> systemProxyForQuery(const QNetworkProxyQuery &query = QNetworkProxyQuery())
bool usesSystemConfiguration()

Detailed Description

The QNetworkProxyFactory class provides fine-grained proxy selection.

QNetworkProxyFactory is an extension to QNetworkProxy, allowing applications to have a more fine-grained control over which proxy servers are used, depending on the socket requesting the proxy. This allows an application to apply different settings, according to the protocol or destination hostname, for instance.

QNetworkProxyFactory can be set globally for an application, in which case it will override any global proxies set with QNetworkProxy::setApplicationProxy(). If set globally, any sockets created with Qt will query the factory to determine the proxy to be used.

A factory can also be set in certain frameworks that support multiple connections, such as QNetworkAccessManager. When set on such object, the factory will be queried for sockets created by that framework only.

System Proxies

You can configure a factory to use the system proxy's settings. Call the setUseSystemConfiguration() function with true to enable this behavior, or false to disable it.

Similarly, you can use a factory to make queries directly to the system proxy by calling its systemProxyForQuery() function.

Warning: Depending on the configuration of the user's system, the use of system proxy features on certain platforms may be subject to limitations. The systemProxyForQuery() documentation contains a list of these limitations for those platforms that are affected.

Member Function Documentation

QNetworkProxyFactory::QNetworkProxyFactory()

Creates a QNetworkProxyFactory object.

Since QNetworkProxyFactory is an abstract class, you cannot create objects of type QNetworkProxyFactory directly.

[virtual] QNetworkProxyFactory::~QNetworkProxyFactory()

Destroys the QNetworkProxyFactory object.

[static] QList<QNetworkProxy> QNetworkProxyFactory::proxyForQuery(const QNetworkProxyQuery &query)

This function takes the query request, query, examines the details of the type of socket or request and returns a list of QNetworkProxy objects that indicate the proxy servers to be used, in order of preference.

[pure virtual] QList<QNetworkProxy> QNetworkProxyFactory::queryProxy(const QNetworkProxyQuery &query = QNetworkProxyQuery())

[static] void QNetworkProxyFactory::setApplicationProxyFactory(QNetworkProxyFactory *factory)

Sets the application-wide proxy factory to be factory. This function will take ownership of that object and will delete it when necessary.

The application-wide proxy is used as a last-resort when all other proxy selection requests returned QNetworkProxy::DefaultProxy. For example, QTcpSocket objects can have a proxy set with QTcpSocket::setProxy, but if none is set, the proxy factory class set with this function will be queried.

If you set a proxy factory with this function, any application level proxies set with QNetworkProxy::setApplicationProxy will be overridden, and usesSystemConfiguration() will return false.

See also QNetworkProxy::setApplicationProxy(), QAbstractSocket::proxy(), and QAbstractSocket::setProxy().

[static] void QNetworkProxyFactory::setUseSystemConfiguration(bool enable)

Enables the use of the platform-specific proxy settings, and only those. See systemProxyForQuery() for more information.

Calling this function with enable set to true resets any proxy or QNetworkProxyFactory that is already set.

Note: See the systemProxyForQuery() documentation for a list of limitations related to the use of system proxies.

This function was introduced in Qt 4.6.

[static] QList<QNetworkProxy> QNetworkProxyFactory::systemProxyForQuery(const QNetworkProxyQuery &query = QNetworkProxyQuery())

[static] bool QNetworkProxyFactory::usesSystemConfiguration()

Returns whether the use of platform-specific proxy settings are enabled.

This function was introduced in Qt 5.8.