Using a proxy

If you want to use a proxy, you first have to set up QNetworkProxy. You can define the type of proxy with setType(). As arguments, you will most likely want to pass QNetworkProxy::Socks5Proxy or QNetworkProxy::HttpProxy. Then, set up the hostname with setHostName(), the username with setUserName(), and the password with setPassword(). The last two properties are, of course, only needed if the proxy requires authentication. Once the proxy is set up, you can set it to the access manager via QNetworkAccessManager::setProxy(). Now, all new requests will use this proxy.

Get Game Programming using Qt 5 Beginner's Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.