当前位置:   article > 正文

Qt操作xml引发内部异常(Qt5Xml.lib和Qt5Xmld.lib)

qt5xmld

在VS2012中使用QT5.1,加载QtXml来操作xml档。可是出了一个很奇怪的问题。下面是实现代码

  1. #include "XmlTest.h"
  2. #include <QtDebug>
  3. void XmlTest::write()
  4. {
  5. QDomDocument document;
  6. QDomElement d=document.createElement("document");
  7. d.setAttribute("name","DocName");
  8. QDomElement a=document.createElement("author");
  9. a.setAttribute("name","AuthorName");
  10. QDomText text=document.createTextNode("Some text");
  11. document.appendChild(d);
  12. d.appendChild(a);
  13. d.appendChild(text);
  14. QFile file("simple.xml");
  15. if (!file.open(QIODevice::WriteOnly|QIODevice::Text))
  16. {
  17. qDebug("Failed to open file for writing.");
  18. return;
  19. }
  20. QTextStream stream(&file);
  21. stream<<document.toString();
  22. file.close();
  23. }
在编译时,出现以下错误

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/781922
推荐阅读
相关标签
  

闽ICP备14008679号