このページでは

QDomDocumentFragment Class

QDomDocumentFragment クラスは、QDomNode のツリーであり、通常は完全なQDomDocument ではありません。詳細...

ヘッダー: #include <QDomDocumentFragment>
CMake: find_package(Qt6 REQUIRED COMPONENTS Xml)
target_link_libraries(mytarget PRIVATE Qt6::Xml)
qmake: QT += xml
継承元: QDomNode

注:このクラスのすべての関数は再入可能です。

パブリック関数

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)

このDOMドキュメントフラグメントにother を割り当てます。

コピーされたデータは共有されます(浅いコピー):一方のノードを変更すると、もう一方も変更されます。深いコピーを作成したい場合は、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.