QDomCharacterData Class
QDomCharacterData 类表示 DOM 中的通用字符串。更多
头文件: | #include <QDomCharacterData> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Xml) target_link_libraries(mytarget PRIVATE Qt6::Xml) |
qmake: | QT += xml |
继承: | QDomNode |
继承于 |
- 所有成员的列表,包括继承成员
- QDomCharacterData 属于XML 类。
注意:该类中的所有函数都是可重入的。
公共函数
QDomCharacterData() | |
QDomCharacterData(const QDomCharacterData &characterData) | |
void | appendData(const QString &arg) |
QString | data() const |
void | deleteData(unsigned long offset, unsigned long count) |
void | insertData(unsigned long offset, const QString &arg) |
int | length() const |
QDomNode::NodeType | nodeType() const |
void | replaceData(unsigned long offset, unsigned long count, const QString &arg) |
void | setData(const QString &data) |
QString | substringData(unsigned long offset, unsigned long count) |
QDomCharacterData & | operator=(const QDomCharacterData &other) |
详细说明
XML 中使用的字符数据指定了一个通用数据字符串。该类更专业的版本有QDomText 、QDomComment 和QDomCDATASection 。
数据字符串用setData() 设置,用data() 检索。使用substringData() 可以检索数据字符串的一部分。使用appendData() 可以追加数据,使用insertData() 可以插入数据。可以使用deleteData() 删除或使用replaceData() 替换数据字符串的部分内容。数据字符串的长度由length() 返回。
nodeType() 将返回包含该字符数据的节点类型。
另请参阅 QDomText,QDomComment, 和QDomCDATASection 。
成员函数文档
QDomCharacterData::QDomCharacterData()
构造一个空字符数据对象。
QDomCharacterData::QDomCharacterData(const QDomCharacterData &characterData)
构造characterData 的副本。
副本的数据是共享的(浅层副本):修改一个节点也会改变另一个节点。如果要进行深度复制,请使用cloneNode() 。
void QDomCharacterData::appendData(const QString &arg)
将字符串arg 追加到存储的字符串中。
QString QDomCharacterData::data() const
返回存储在此对象中的字符串。
如果节点是null node ,则返回空字符串。
另请参见 setData()。
void QDomCharacterData::deleteData(unsigned long offset, unsigned long count)
从offset 位置删除长度为count 的子串。
void QDomCharacterData::insertData(unsigned long offset, const QString &arg)
将字符串arg 插入存储字符串的offset 位置。
int QDomCharacterData::length() const
返回存储字符串的长度。
QDomNode::NodeType QDomCharacterData::nodeType() const
返回此对象指向的节点类型(即TextNode
,CDATASectionNode
,CommentNode
或CharacterDataNode
)。对于null node ,返回CharacterDataNode
。
void QDomCharacterData::replaceData(unsigned long offset, unsigned long count, const QString &arg)
用字符串arg 替换从位置offset 开始的长度为count 的子字符串。
void QDomCharacterData::setData(const QString &data)
将此对象的字符串设置为data 。
另请参见 data()。
QString QDomCharacterData::substringData(unsigned long offset, unsigned long count)
从位置offset 开始,返回长度为count 的子串。
QDomCharacterData &QDomCharacterData::operator=(const QDomCharacterData &other)
为该字符数据指定other 。
拷贝的数据是共享的(浅拷贝):修改一个节点也会改变另一个节点。如果要进行深度复制,请使用cloneNode()。
© 2025 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.