Even for QNetworkAccessManager, you should take a look at this signal:
http://doc.trolltech.com/4.5/qnetwor...cationRequired
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
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);
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
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;
}
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
kissfire (16th November 2009)
QNetworkaccessmanager is worked!
thanks a lot ,mgoetz!
many thanks!
Glad it works![]()
Disclaimer: Although I work on Qt for Nokia, anything I post here is personal
Bookmarks