QXmlStreamAttribute Class

QXmlStreamAttribute 类表示单个 XML 属性。更多

头文件: #include <QXmlStreamAttribute>
CMake.QXmlStreamAttribute find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core

该类可等价比较

注意:该类中的所有函数都是可重入的

公共函数

QXmlStreamAttribute()
QXmlStreamAttribute(const QString &qualifiedName, const QString &value)
QXmlStreamAttribute(const QString &namespaceUri, const QString &name, const QString &value)
bool isDefault() const
QStringView name() const
QStringView namespaceUri() const
QStringView prefix() const
QStringView qualifiedName() const
QStringView value() const
bool operator!=(const QXmlStreamAttribute &lhs, const QXmlStreamAttribute &rhs)
bool operator==(const QXmlStreamAttribute &lhs, const QXmlStreamAttribute &rhs)

详细描述

一个属性由一个可选的空namespaceUri() 、一个name() 、一个value() 和一个isDefault() 属性组成。

原始 XML 属性名以qualifiedName() 的形式返回。

成员函数文档

QXmlStreamAttribute::QXmlStreamAttribute()

创建一个空属性。

QXmlStreamAttribute::QXmlStreamAttribute(const QString &qualifiedName, const QString &value)

构造一个属性,其限定名称为qualifiedName ,值为value

QXmlStreamAttribute::QXmlStreamAttribute(const QString &namespaceUri, const QString &name, const QString &value)

namespaceUri 所描述的命名空间中构建一个属性,该属性的名称为name ,值为value

bool QXmlStreamAttribute::isDefault() const

如果解析器在 DTD 中的 ATTLIST 声明后添加了带有默认值的该属性,则返回true ;否则返回false

QStringView QXmlStreamAttribute::name() const

返回属性的本地名称。

QStringView QXmlStreamAttribute::namespaceUri() const

返回属性的已解析命名空间 Uri,如果属性没有已定义的命名空间,则返回空字符串引用。

QStringView QXmlStreamAttribute::prefix() const

返回属性的命名空间前缀。

另请参阅 name() 和qualifiedName()。

QStringView QXmlStreamAttribute::qualifiedName() const

返回属性的限定名称。

限定名称是 XML 数据中属性的原始名称。它由命名空间prefix ()、冒号和属性的本地name ()组成。由于命名空间前缀不是唯一的(相同的前缀可以指向不同的命名空间,不同的前缀也可以指向相同的命名空间),因此不应使用 qualifiedName(),而应使用解析后的namespaceUri() 和属性的本地name()。

QStringView QXmlStreamAttribute::value() const

返回属性值。

相关非成员

[noexcept] bool operator!=(const QXmlStreamAttribute &lhs, const QXmlStreamAttribute &rhs)

lhs 属性与rhs 属性进行比较,如果不相等,则返回true ;否则返回false

[noexcept] bool operator==(const QXmlStreamAttribute &lhs, const QXmlStreamAttribute &rhs)

lhs 属性与rhs 属性进行比较,如果两者相等,则返回true ;否则返回false

© 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.