[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!

    @ 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);
    }@



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.