我试图使用 QNetworkAccessmanager 向 localhost/conductor/api/provider_accounts.xml 发送请求,但问题是当我用浏览器打开它时,我得到了适当的输出,但是当我对 QNetworkAccessmanager 做同样的事情时,我什么也没有得到一点也不。这是我的代码
void ServiceProvider::replyFinished(QNetworkReply * reply)
{
qDebug()<<reply->readAll();
QString data=(QString)reply->readAll();
qDebug()<<data;
QXmlStreamReader xml(data);
QXmlStreamAttributes attrib;
while(!xml.atEnd()){
xml.readNextStartElement();
if(xml.name()=="name" && !xml.isEndElement()){
attrib=xml.attributes();
QString name=attrib.value("name").toString();
qDebug()<<name;
}
}
}
void ServiceProvider::pushImage()
{
manager = new QNetworkAccessManager(this);
manager->get(QNetworkRequest(QUrl("https://localhost/conductor
/api/provider_accounts.xml")));
connect(manager, SIGNAL(finished(QNetworkReply*)),
this, SLOT(replyFinished(QNetworkReply*)));
}