QOpcUaGenericStructValue Class
保存通用 OPC UA 结构类型的值。更多
头文件: | #include <QOpcUaGenericStructValue> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS OpcUa) target_link_libraries(mytarget PRIVATE Qt6::OpcUa) |
qmake: | QT += opcua |
自 | Qt 6.7 |
公共函数
QOpcUaGenericStructValue() | |
QOpcUaGenericStructValue(const QString &typeName, const QString &typeId, const QOpcUaStructureDefinition &definition) | |
QOpcUaGenericStructValue(const QString &typeName, const QString &typeId, const QOpcUaStructureDefinition &definition, const QHash<QString, QVariant> &fields) | |
QOpcUaGenericStructValue(const QOpcUaGenericStructValue &other) | |
QOpcUaGenericStructValue(QOpcUaGenericStructValue &&other) | |
~QOpcUaGenericStructValue() | |
QHash<QString, QVariant> | fields() const |
QHash<QString, QVariant> & | fieldsRef() |
void | setFields(const QHash<QString, QVariant> &fields) |
void | setStructureDefinition(const QOpcUaStructureDefinition &structureDefinition) |
void | setTypeId(const QString &typeId) |
void | setTypeName(const QString &typeName) |
QOpcUaStructureDefinition | structureDefinition() const |
void | swap(QOpcUaGenericStructValue &other) |
QString | toString() const |
QString | typeId() const |
QString | typeName() const |
QVariant | operator QVariant() const |
QOpcUaGenericStructValue & | operator=(QOpcUaGenericStructValue &&other) |
QOpcUaGenericStructValue & | operator=(const QOpcUaGenericStructValue &rhs) |
相关非成员
bool | operator!=(const QOpcUaGenericStructValue &lhs, const QOpcUaGenericStructValue &rhs) |
QDebug | operator<<(QDebug debug, const QOpcUaGenericStructValue &s) |
bool | operator==(const QOpcUaGenericStructValue &lhs, const QOpcUaGenericStructValue &rhs) |
详细说明
该类包含一个通用 OPC UA 结构值,该结构值由命名字段及其值组成,这些字段可以是内置类型或其子类型,也可以是其他嵌套的通用结构。该类对象中还包含一些元信息,如类型 ID 和类型的结构定义。
它被用作QOpcUaGenericStructHandler 解码结果的返回类型和编码方法的输入类型。
对于带有可选字段的结构体,fields() 列表中只包含指定的字段。要在编码过程中省略可选字段,该字段必须不出现在fields() 列表中。对于从 Union 类型派生的结构体,必须只指定其中一个字段。解码后类型的fields() 列表中的唯一条目将决定类型定义中的哪个字段(如果有的话)被指定。
示例
// 解码扩展对象QOpcUaGenericStructValuevalue=decoder.decode(extensionObject,success);// 打印必填字段的值qDebug() << value.fields().value("MyField").value<QOpcUaLocalizedText>(); // 打印可选字段的值if(value.fields().contains("MyOptionalField")) qDebug() << value.fields().value("MyField").value<QOpcUaQualifiedName>(); // 获取字段的嵌套结构const autounionMember=value.fields().value("MyUnionMember").value<QOpcUaGenericStructValue>();// 打印指定字段if(unionMember.fields().contains("UnionMember1")) qDebug() << unionMember.fields().value("UnionMember1").toInt(); else if(unionMember.fields().contains("UnionMember2")) qDebug() << unionMember.fields().value("UnionMember2").toDouble(); 不然 qDebug() << "Empty union";
成员函数文档
QOpcUaGenericStructValue::QOpcUaGenericStructValue()
构造一个通用结构值。
QOpcUaGenericStructValue::QOpcUaGenericStructValue(const QString &typeName, const QString &typeId, const QOpcUaStructureDefinition &definition)
从typeName 、typeId 和definition 构建一个通用结构值。
QOpcUaGenericStructValue::QOpcUaGenericStructValue(const QString &typeName, const QString &typeId, const QOpcUaStructureDefinition &definition, const QHash<QString, QVariant> &fields)
从typeName,typeId,definition 和fields 构建通用结构值。
QOpcUaGenericStructValue::QOpcUaGenericStructValue(const QOpcUaGenericStructValue &other)
从other 构建通用结构值。
[noexcept]
QOpcUaGenericStructValue::QOpcUaGenericStructValue(QOpcUaGenericStructValue &&other)
移动--从other 构建一个新的通用结构体值。
注意: move-from 对象other 处于部分形成状态,在这种状态下,唯一有效的操作是销毁和赋值。
[noexcept]
QOpcUaGenericStructValue::~QOpcUaGenericStructValue()
销毁此通用结构值对象。
QHash<QString, QVariant> QOpcUaGenericStructValue::fields() const
返回此通用结构值的字段。
另请参见 setFields()。
QHash<QString, QVariant> &QOpcUaGenericStructValue::fieldsRef()
返回对该通用结构值字段的引用。
void QOpcUaGenericStructValue::setFields(const QHash<QString, QVariant> &fields)
将此通用结构值的字段设置为fields 。
另请参见 fields()。
void QOpcUaGenericStructValue::setStructureDefinition(const QOpcUaStructureDefinition &structureDefinition)
将此通用结构值的结构定义设置为structureDefinition 。
另请参见 structureDefinition() 。
void QOpcUaGenericStructValue::setTypeId(const QString &typeId)
将此通用结构值的类型节点 id 设置为typeId 。
另请参阅 typeId() 。
void QOpcUaGenericStructValue::setTypeName(const QString &typeName)
将此通用结构体值的类型名称设置为typeName 。
另请参阅 typeName() 。
QOpcUaStructureDefinition QOpcUaGenericStructValue::structureDefinition() const
返回此通用结构值的结构定义。
另请参见 setStructureDefinition()。
[noexcept]
void QOpcUaGenericStructValue::swap(QOpcUaGenericStructValue &other)
将通用结构值对象other 与此通用结构值对象互换。该操作速度非常快,而且从未出现过故障。
QString QOpcUaGenericStructValue::toString() const
返回该通用结构值的字符串表示。
QString QOpcUaGenericStructValue::typeId() const
返回此通用结构值的类型节点 ID。
另请参见 setTypeId()。
QString QOpcUaGenericStructValue::typeName() const
返回该通用结构值的类型名称。
另请参见 setTypeName()。
QVariant QOpcUaGenericStructValue::operator QVariant() const
返回包含此通用结构值的QVariant 。
[noexcept]
QOpcUaGenericStructValue &QOpcUaGenericStructValue::operator=(QOpcUaGenericStructValue &&other)
移动--将other 赋值给此QOpcUaGenericStructValue 实例。
注意: 从移动对象other 将处于部分形成状态,其中唯一有效的操作是销毁和赋新值。
QOpcUaGenericStructValue &QOpcUaGenericStructValue::operator=(const QOpcUaGenericStructValue &rhs)
设置rhs 的值。
相关非成员
[noexcept]
bool operator!=(const QOpcUaGenericStructValue &lhs, const QOpcUaGenericStructValue &rhs)
如果lhs 不等于rhs ,则返回true
。
QDebug operator<<(QDebug debug, const QOpcUaGenericStructValue &s)
将s 的字符串表示输出到debug 中。
[noexcept]
bool operator==(const QOpcUaGenericStructValue &lhs, const QOpcUaGenericStructValue &rhs)
如果lhs 等于rhs ,则返回true
。
© 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.