Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED]The following code for setting proxy fails in case of manual proxy settings
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]The following code for setting proxy fails in case of manual proxy settings

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    adnan
    wrote on last edited by
    #1

    What is wrong with the code:
    if i use system proxy the error displayed is "connection refused"
    and if i use manual proxy (proxy address being same) error displayed is "Host not found"

    The proxy server is squid with proxy-address:172.16.28.11 and port:3128

    Besides, it also doesn't work for localhost proxy like the one created using tor or dynamic port forwarding!

    @ if(settDialog.ui->no_proxy->isChecked())
    {
    QNetworkProxyFactory::setUseSystemConfiguration (false);
    QNetworkProxy::setApplicationProxy(QNetworkProxy::NoProxy);
    }
    else if(settDialog.ui->use_s_proxy->isChecked())
    {
    QNetworkProxyFactory::setUseSystemConfiguration (true);
    }
    else if(settDialog.ui->man_proxy->isChecked())
    {
    QNetworkProxyFactory::setUseSystemConfiguration (false);
    proxy.setHostName(settDialog.ui->proxy_addr->text());
    proxy.setPort(settDialog.ui->port_num->value());
    if(settDialog.ui->proxyType->currentIndex()==0)
    proxy.setType(QNetworkProxy::HttpProxy);
    else if(settDialog.ui->proxyType->currentIndex()==1)
    proxy.setType(QNetworkProxy::Socks5Proxy);
    else if(settDialog.ui->proxyType->currentIndex()==2)
    proxy.setType(QNetworkProxy::FtpCachingProxy);
    proxy.setHostName(settDialog.ui->username->text());
    proxy.setPassword(settDialog.ui->pwd->text());
    QNetworkProxy::setApplicationProxy(proxy);
    }@

    1 Reply Last reply
    0
    • A Offline
      A Offline
      adnan
      wrote on last edited by
      #2

      @if(!settDialog.ui->username->text().isEmpty())
      proxy.setHostName(settDialog.ui->username->text()); if(!settDialog.ui->pwd->text().isEmpty())
      proxy.setPassword(settDialog.ui->pwd->text());@

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved