network connectivity with proxy


in Knights and in LabPlot I realized recently, while being in a corporate
network behind a proxy, that the connection to public internet servers is not
possible. E.g. in Khights the connection to the FICS-server is done like

QTcpSocket* socket = new QTcpSocket(this);
socket->connectToHost(address, port);

How to properly handle the proxy settings? Reading system settings (from the
environment?) and calling QTcpSocket::setProxy() or
QNetworkProxy::setApplicationProxy() somewhere in main.cpp doesn't sound to
me like the "standard way to do this".

In KDE's system settings there're already settings for the proxy. How to use
them and how to deal with this on windows and mac os x where this is not
available? Should the applications have this configuration in their settings?



Re: network connectivity with proxy

By Harald Sitter at 09/12/2018 - 06:17

On Mon, Sep 10, 2018 at 10:31 PM Alexander Semke <alexander. ... at web dot de> wrote:
If I am not mistaken Qt already looks in the environment variables for
http_proxy, https_proxy etc. etc. (I don't think Plasma sets those
from the KCM though). To that end a no-code solution is setting those.
Obviously that's not very integrated in plasma.

There is KTcpSocket (in KIO). But at a glance I don't actually see the
class implementing proxy handling correctly, nor does it look
particularly well documented, so I am not sure it should be used.
So... maybe fix KTcpSocket first, then use it ;)

KProtocolManager is the way to get the proxy settings in your
application from which you can construct a QNetworkProxy and set that
either on an application level or per-socket (you should be able to
find some examples of that via

That's not ideal I'd have to say though. On OSX and Windows figures
the proxy stuff out automatically as far as I know (KProtocolManager
would be falling back to QNetwork on those platforms I'd presume).

[1] <a href="" title=""></a>


Re: network connectivity with proxy

By Thiago Macieira at 09/14/2018 - 11:04

On Wednesday, 12 September 2018 04:17:35 PDT Harald Sitter wrote:
The correct way is to configure your system properly. Qt will use libproxy and
will get the settings.

Re: network connectivity with proxy

By Albert Astals Cid at 09/19/2018 - 17:03

El divendres, 14 de setembre de 2018, a les 18:04:59 CEST, Thiago Macieira va escriure:
So this should be a bug reported against systemsettings or kded or something then?


Re: network connectivity with proxy

By Christoph Feck at 09/19/2018 - 17:20

On 20.09.2018 00:03, Albert Astals Cid wrote:
libproxy can be compiled with KF5 support, so it can automatically read
the proxy settings that kcm_proxy writes. The problem is that this
support is/was disabled by default, because of
<a href="" title=""></a>

Distributions might need to check if they need to re-enable it.

Re: network connectivity with proxy

By Thiago Macieira at 09/21/2018 - 19:24

On Wednesday, 19 September 2018 15:20:27 PDT Christoph Feck wrote:
libproxy tries to detect if you're running a Qt5 application.

In any case, I recommend using the pacrunner's libproxy instead of libproxy's
libproxy. The proxy settings won't be read from KDE's. Instead, they will be
centralised in the pacrunner daemon. KDE should provision it (it's just a D-
Bus call, plasma-nm can do it).