我有 QDomNode
对象,我需要获取其中数据的 html 表示形式。我找到了一个方法 QDomNode::save( QTextStream & str, int indent ) :
Writes the XML representation of the node and all its children to the stream str. This function uses indent as the amount of space to indent the node.
我试过这样使用它:
QDomNode table = ...;
QString *htmlTable;
QTextStream stream(htmlTable);
table.save(stream, 2);
qDebug() << htmlTable;
QDebug 返回一个指针。在其他情况下,程序会失败。我想我用错了 QTextStream
。
最佳答案
您还没有为您的 QString 保留内存。
QString htmlTable;
QTextStream stream(&htmlTable);
table.save(stream, 2);
应该可以,但我还没有测试过。
关于c++ - QDomNode 到 html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6817242/