Results 1 to 10 of 10

Thread: For help!why QHttp,QNetworkProxy set proxy with username and password failed?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2009
    Posts
    37
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11
    Thanked 4 Times in 4 Posts

    Default Re: For help!why QHttp,QNetworkProxy set proxy with username and password failed?

    Even for QNetworkAccessManager, you should take a look at this signal:

    http://doc.trolltech.com/4.5/qnetwor...cationRequired
    Disclaimer: Although I work on Qt for Nokia, anything I post here is personal

  2. #2
    Join Date
    Nov 2009
    Posts
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    1

    Default Re: For help!why QHttp,QNetworkProxy set proxy with username and password failed?

    Hi mgoetz:
    I read the article you remended,then I tried ,but still failed,I dont know why,here is the codes,can you kindly give me some suggestions or solutions for proxy(password + username) writted with QNetworkAccessManager?
    Thx a lot!
    here is the code:
    [
    QNetworkAccessManager* qnam = new QNetworkAccessManager(this);

    connect(qnam, SIGNAL(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)), this,
    SIGNAL(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)));

    QNetworkProxy proxy;
    proxy.setType(QNetworkProxy::HttpProxy);
    proxy.setHostName(pProxyInfo->qstrProxyServerName);
    proxy.setPort(pProxyInfo->qstrProxyPort.toInt());
    proxy.setUser(pProxyInfo->qstrProxyUserName);
    proxy.setPassword(pProxyInfo->qstrProxyPassWord);

    qnam->setProxy(proxy);

  3. #3
    Join Date
    Oct 2009
    Posts
    37
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11
    Thanked 4 Times in 4 Posts

    Default Re: For help!why QHttp,QNetworkProxy set proxy with username and password failed?

    Yes
    You should read about Qt signals and slots. I think you need a slot that sets the authentication parameters.

    http://doc.trolltech.com/4.5/signalsandslots.html
    Disclaimer: Although I work on Qt for Nokia, anything I post here is personal

  4. #4
    Join Date
    Nov 2009
    Posts
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    1

    Default Re: For help!why QHttp,QNetworkProxy set proxy with username and password failed?

    Add slot and response Func:reponseRecue,but stiil failed ,why???,It seems that i cant get the response message,bcz reponseRecue,not entered,and the dialogue says:detecting...
    why???

    [
    QNetworkAccessManager* qnam = new QNetworkAccessManager(this);


    connect(qnam, SIGNAL(finished(QNetworkReply *)), this, SLOT(reponseRecue(QNetworkReply*)));

    connect(qnam, SIGNAL(authenticationRequired(QNetworkReply*,QAuth enticator*)),
    this, SLOT(authenticate(QNetworkReply*,QAuthenticator*)) );

    connect(qnam, SIGNAL(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)),
    this, SLOT(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)));

    //begin mod
    QNetworkProxy proxy;
    proxy.setType(QNetworkProxy::HttpProxy);
    /*proxy.setType(QNetworkProxy::Socks5Proxy);*/
    proxy.setHostName(pProxyInfo->qstrProxyServerName);
    proxy.setPort(pProxyInfo->qstrProxyPort.toInt());
    proxy.setUser(pProxyInfo->qstrProxyUserName);
    proxy.setPassword(pProxyInfo->qstrProxyPassWord);
    //QNetworkProxy::setApplicationProxy(proxy);*/

    /*m_pTestHttpObj->setProxy(proxy);*/
    qnam->setProxy(proxy);


    ....
    ....
    void XXX::reponseRecue(QNetworkReply* reply)
    {
    CDlgSetting* pSet = (CDlgSetting*)m_pSet;
    if (reply->error() == QNetworkReply::NoError)
    {
    pSet->OnCheckNetConnectSuccess();
    qDebug() << reply->readAll();
    QMessageBox::information(0, tr("Connection"), tr("ok"));
    }
    else
    {
    pSet->OnCheckNetConnectFaild();

    QMessageBox::information(0, tr("Connection"), tr("Err !"));
    }

    m_pSet = NULL;
    delete reply;
    }

  5. #5
    Join Date
    Oct 2009
    Posts
    37
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11
    Thanked 4 Times in 4 Posts

    Default Re: For help!why QHttp,QNetworkProxy set proxy with username and password failed?

    Please look into demos/browser/networkaccessmanager.cpp in the Qt source to see how proxyAuthenticationRequired is used there.
    Disclaimer: Although I work on Qt for Nokia, anything I post here is personal

  6. The following user says thank you to mgoetz for this useful post:

    kissfire (16th November 2009)

  7. #6
    Join Date
    Nov 2009
    Posts
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    1

    Talking Re: For help!why QHttp,QNetworkProxy set proxy with username and password failed?

    QNetworkaccessmanager is worked!
    thanks a lot ,mgoetz!
    many thanks!

  8. #7
    Join Date
    Oct 2009
    Posts
    37
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11
    Thanked 4 Times in 4 Posts

    Default Re: For help!why QHttp,QNetworkProxy set proxy with username and password failed?

    Glad it works
    Disclaimer: Although I work on Qt for Nokia, anything I post here is personal

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.