QXmlAttributes Class
QXmlAttributes 类提供 XML 属性。更多
头文件: | #include <QXmlAttributes> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Core5Compat) target_link_libraries(mytarget PRIVATE Qt6::Core5Compat) |
qmake: | QT += core5compat |
注意:该类中的所有函数都是可重入的。
公共函数
QXmlAttributes() | |
virtual | ~QXmlAttributes() |
void | append(const QString &qName, const QString &uri, const QString &localPart, const QString &value) |
void | clear() |
int | count() const |
int | index(const QString &qName) const |
int | index(QLatin1String qName) const |
int | index(const QString &uri, const QString &localPart) const |
int | length() const |
QString | localName(int index) const |
QString | qName(int index) const |
void | swap(QXmlAttributes &other) |
QString | type(int index) const |
QString | type(const QString &qName) const |
QString | type(const QString &uri, const QString &localName) const |
QString | uri(int index) const |
QString | value(int index) const |
QString | value(QLatin1String qName) const |
QString | value(const QString &qName) const |
QString | value(const QString &uri, const QString &localName) const |
详细说明
如果属性由QXmlContentHandler::startElement() 报告,则该类用于传递属性值。
使用index() 查找属性在列表中的位置,使用count() 获取属性的数量,使用clear() 删除属性。使用append() 可以添加新属性。使用type() 获取属性类型,使用value() 获取属性值。属性名称可通过localName() 或qName() 获取,其命名空间 URI 可通过uri() 获取。
成员函数文档
QXmlAttributes::QXmlAttributes()
构造一个空属性列表。
[virtual noexcept]
QXmlAttributes::~QXmlAttributes()
销毁属性对象。
void QXmlAttributes::append(const QString &qName, const QString &uri, const QString &localPart, const QString &value)
在属性列表中添加一个新的属性条目。属性的限定名称是qName ,命名空间 URI 是uri ,本地名称是localPart 。属性值为value 。
另请参阅 qName()、uri()、localName() 和value()。
void QXmlAttributes::clear()
清除属性列表。
另请参阅 append()。
int QXmlAttributes::count() const
返回列表中属性的数量。此函数等同于length()。
int QXmlAttributes::index(const QString &qName) const
通过限定名称qName 查找属性索引。
返回属性索引,如果未找到,则返回-1。
int QXmlAttributes::index(QLatin1String qName) const
这是一个重载函数。
int QXmlAttributes::index(const QString &uri, const QString &localPart) const
这是一个重载函数。
根据名称空间名称查找属性索引。
uri localPart 指定属性的本地名称。
返回属性的索引,如果未找到,则返回-1。
int QXmlAttributes::length() const
返回列表中属性的数量。
另请参阅 count()。
QString QXmlAttributes::localName(int index) const
查找位置index 的属性的本地名称。如果没有进行名称空间处理,则本地名称为空字符串。
QString QXmlAttributes::qName(int index) const
查找位于index 位置的属性的 XML 1.0 限定名称。
[noexcept]
void QXmlAttributes::swap(QXmlAttributes &other)
将this
与other 互换。
QString QXmlAttributes::type(int index) const
查找index 位置的属性类型。
目前只返回 "CDATA"。
QString QXmlAttributes::type(const QString &qName) const
这是一个重载函数。
根据限定名称qName 查找属性类型。
目前只返回 "CDATA"。
QString QXmlAttributes::type(const QString &uri, const QString &localName) const
这是一个重载函数。
根据命名空间名称查找属性类型。
uri 指定名称空间 URI, 指定本地名称。如果名称中没有名称空间 URI,则使用空字符串 。localName uri
目前只返回 "CDATA"。
QString QXmlAttributes::uri(int index) const
查找位置index 的属性的命名空间 URI。如果没有进行命名空间处理或属性没有命名空间,则命名空间 URI 为空字符串。
QString QXmlAttributes::value(int index) const
返回位于index 位置的属性值。索引必须是有效位置(即 0 <=index <count() )。
QString QXmlAttributes::value(QLatin1String qName) const
这是一个重载函数。
返回限定名称qName 的属性值,如果给定名称不存在属性,则返回空字符串。
QString QXmlAttributes::value(const QString &qName) const
这是一个重载函数。
返回限定名称qName 的属性值,如果给定名称不存在属性,则返回空字符串。
QString QXmlAttributes::value(const QString &uri, const QString &localName) const
这是一个重载函数。
按名称空间名称返回属性值。
uri localName 指定属性的本地名称。
© 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.