August 12, 2012

adnan adnan
Hobby Entomologist
269 posts

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

 

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!

  1.  if(settDialog.ui->no_proxy->isChecked())
  2.     {
  3.         QNetworkProxyFactory::setUseSystemConfiguration (false);
  4.         QNetworkProxy::setApplicationProxy(QNetworkProxy::NoProxy);
  5.     }
  6.     else if(settDialog.ui->use_s_proxy->isChecked())
  7.     {
  8.         QNetworkProxyFactory::setUseSystemConfiguration (true);
  9.     }
  10.     else if(settDialog.ui->man_proxy->isChecked())
  11.     {
  12.         QNetworkProxyFactory::setUseSystemConfiguration (false);
  13.         proxy.setHostName(settDialog.ui->proxy_addr->text());
  14.         proxy.setPort(settDialog.ui->port_num->value());
  15.         if(settDialog.ui->proxyType->currentIndex()==0)
  16.             proxy.setType(QNetworkProxy::HttpProxy);
  17.         else if(settDialog.ui->proxyType->currentIndex()==1)
  18.             proxy.setType(QNetworkProxy::Socks5Proxy);
  19.         else if(settDialog.ui->proxyType->currentIndex()==2)
  20.             proxy.setType(QNetworkProxy::FtpCachingProxy);
  21.         proxy.setHostName(settDialog.ui->username->text());
  22.         proxy.setPassword(settDialog.ui->pwd->text());
  23.         QNetworkProxy::setApplicationProxy(proxy);
  24.     }

1 reply

August 13, 2012

adnan adnan
Hobby Entomologist
269 posts

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

 
  ‹‹ How to differentiate between tablet buttons using QTabletEvent?      Rendering a QGraphicsTextItem with ObjectReplacementCharacter ››

You must log in to post a reply. Not a member yet? Register here!