本页内容

QXmlStreamAttribute Class

QXmlStreamAttribute 类表示一个 XML 属性。更多内容...

标题: #include <QXmlStreamAttribute>
CMake: find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core

注意:该类中的所有函数均为可重入函数。

QXmlStreamAttribute 比较

类别可比较类型
相等性QXmlStreamAttribute

公共函数

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 。

该属性的isDefault()将等于false 。

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

在由namespaceUri 描述的命名空间中,使用name 和值value 创建一个属性。

该属性的isDefault()将等于false 。

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 。

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