QDomDocumentFragment Class
QDomDocumentFragment 类是一个由 QDomNodes 组成的树,通常并非完整的QDomDocument 。更多内容...
| 头文件: | #include <QDomDocumentFragment> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Xml) target_link_libraries(mytarget PRIVATE Qt6::Xml) |
| qmake: | QT += xml |
| 继承自: | QDomNode |
- 所有成员列表(包括继承的成员)
- QDomDocumentFragment 属于XML 类。
注意:该类中的所有函数均为可重入函数。
公共函数
| QDomDocumentFragment() | |
| QDomDocumentFragment(const QDomDocumentFragment &documentFragment) | |
| QDomNode::NodeType | nodeType() const |
| QDomDocumentFragment & | operator=(const QDomDocumentFragment &other) |
详细说明
如果您想进行复杂的树操作,有一个轻量级的类来存储节点及其关系会非常有用。QDomDocumentFragment 存储文档的一个子树,该子树不一定代表一个结构良好的 XML 文档。
如果您想将多个节点分组到一个列表中,并将其全部作为某个节点的子节点插入,QDomDocumentFragment 也很有用。在这些情况下,QDomDocumentFragment 可以作为该子节点列表的临时容器。
QDomDocumentFragment 最重要的特点在于,QDomNode::insertAfter()、QDomNode::insertBefore()、QDomNode::replaceChild() 和QDomNode::appendChild() 会对其进行特殊处理:它们不会插入片段本身,而是插入该片段的所有子节点。
成员函数文档
QDomDocumentFragment::QDomDocumentFragment()
构建一个空的文档片段。
QDomDocumentFragment::QDomDocumentFragment(const QDomDocumentFragment &documentFragment)
创建documentFragment 的副本。
该副本的数据是共享的(浅拷贝):修改其中一个节点也会改变另一个节点。若要进行深拷贝,请使用cloneNode()。
QDomNode::NodeType QDomDocumentFragment::nodeType() const
返回DocumentFragment 。
另请参阅 isDocumentFragment() 和QDomNode::toDocumentFragment()。
QDomDocumentFragment &QDomDocumentFragment::operator=(const QDomDocumentFragment &other)
将other 分配给此DOM文档片段。
复制的数据是共享的(浅拷贝):修改一个节点也会改变另一个节点。如果要进行深拷贝,请使用 `cloneNode()`。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.