我收到的字符串作爲這個功能的XML文檔與QDomDocument對象讀取字符串作爲XML:如何在QT
void HttpWindow::replyFinished(QNetworkReply *reply)
{
QString data = reply->readAll().trimmed();
bool value=document->setContent(&data);
}
,這裏是我的插槽和信號:
connect(reply, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));
當我把上面的代碼我得到的錯誤,沒有預先定義的函數接收一個字符串,因爲我已經發表了...可以somone試圖糾正這個,所以我可以看到如何把這個Qstring值放入xml文檔。因此,我可以讀取XML
謝謝
編輯: 這些都是我必須選擇的功能,我已經嘗試了所有,但似乎我不發送正確paremeters:
// Qt extensions
bool setContent(const QByteArray& text, bool namespaceProcessing, QString *errorMsg=0, int *errorLine=0, int *errorColumn=0);
bool setContent(const QString& text, bool namespaceProcessing, QString *errorMsg=0, int *errorLine=0, int *errorColumn=0);
bool setContent(QIODevice* dev, bool namespaceProcessing, QString *errorMsg=0, int *errorLine=0, int *errorColumn=0);
bool setContent(QXmlInputSource *source, bool namespaceProcessing, QString *errorMsg=0, int *errorLine=0, int *errorColumn=0);
bool setContent(const QByteArray& text, QString *errorMsg=0, int *errorLine=0, int *errorColumn=0);
bool setContent(const QString& text, QString *errorMsg=0, int *errorLine=0, int *errorColumn=0);
bool setContent(QIODevice* dev, QString *errorMsg=0, int *errorLine=0, int *errorColumn=0);
bool setContent(QXmlInputSource *source, QXmlReader *reader, QString *errorMsg=0, int *errorLine=0, int *errorColumn=0);
編輯2: 我不能編譯它,我可以給你這樣的代碼:
httpwindow.cpp: In member function 'void HttpWindow::replyFinished(QNetworkReply*)':
httpwindow.cpp:140: error: no matching function for call to 'QDomDocument::setContent(QString*)'
..\..\..\..\Desktop\Qt\4.7.4\mingw\include/QtXml/qdom.h:343: note: candidates are: bool QDomDocument::setContent(const QByteArray&, bool, QString*, int*, int*)
..\..\..\..\Desktop\Qt\4.7.4\mingw\include/QtXml/qdom.h:344: note: bool QDomDocument::setContent(const QString&, bool, QString*, int*, int*)
..\..\..\..\Desktop\Qt\4.7.4\mingw\include/QtXml/qdom.h:345: note: bool QDomDocument::setContent(QIODevice*, bool, QString*, int*, int*)
..\..\..\..\Desktop\Qt\4.7.4\mingw\include/QtXml/qdom.h:346: note: bool QDomDocument::setContent(QXmlInputSource*, bool, QString*, int*, int*)
..\..\..\..\Desktop\Qt\4.7.4\mingw\include/QtXml/qdom.h:347: note: bool QDomDocument::setContent(const QByteArray&, QString*, int*, int*)
..\..\..\..\Desktop\Qt\4.7.4\mingw\include/QtXml/qdom.h:348: note: bool QDomDocument::setContent(const QString&, QString*, int*, int*)
..\..\..\..\Desktop\Qt\4.7.4\mingw\include/QtXml/qdom.h:349: note: bool QDomDocument::setContent(QIODevice*, QString*, int*, int*)
..\..\..\..\Desktop\Qt\4.7.4\mingw\include/QtXml/qdom.h:350: note: bool QDomDocument::setContent(QXmlInputSource*, QXmlReader*, QString*, int*, int*)
或者告訴我怎樣做才能拿到Qdebug輸出。你的意思是像Qdebug<<data
?
你能發佈「數據」調試輸出嗎 – Neox