QOpcUaGenericStructValue Class
Almacena el valor de un tipo estructurado genérico de OPC UA. Más información...
| Encabezado: | #include <QOpcUaGenericStructValue> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS OpcUa) target_link_libraries(mytarget PRIVATE Qt6::OpcUa) |
| qmake: | QT += opcua |
| Desde: | Qt 6.7 |
Funciones públicas
| 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 |
| operator QVariant() const | |
| QOpcUaGenericStructValue & | operator=(QOpcUaGenericStructValue &&other) |
| QOpcUaGenericStructValue & | operator=(const QOpcUaGenericStructValue &rhs) |
Elementos no miembros relacionados
| bool | operator!=(const QOpcUaGenericStructValue &lhs, const QOpcUaGenericStructValue &rhs) |
| QDebug | operator<<(QDebug debug, const QOpcUaGenericStructValue &s) |
| bool | operator==(const QOpcUaGenericStructValue &lhs, const QOpcUaGenericStructValue &rhs) |
Descripción detallada
Esta clase contiene un valor de estructura genérica OPC UA que consta de campos con nombre y sus respectivos valores, los cuales pueden ser tipos integrados o sus subtipos, así como otras estructuras genéricas anidadas. También se incluye cierta metainformación, como el identificador del tipo y la definición de la estructura del tipo contenido en un objeto de esta clase.
Se utiliza como tipo de retorno para el resultado de la decodificación y como tipo de entrada para el método de codificación de QOpcUaGenericStructHandler.
En el caso de una estructura con campos opcionales, solo los campos que se hayan especificado figuran en la lista ` fields() `. Para omitir un campo opcional durante la codificación, este no debe aparecer en la lista ` fields()`. En el caso de las estructuras derivadas del tipo «Union», solo debe especificarse uno de los campos. La única entrada de la lista fields() de un tipo decodificado determina qué campo (si lo hay) de la definición del tipo se ha especificado.
Ejemplo:
// Decodificar un objeto de extensión
QOpcUaGenericStructValue value = decoder.decode(extensionObject, success);
// Imprimir el valor de un campo obligatorio
qDebug() << value.fields().value("MyField").value<QOpcUaLocalizedText>();
// Imprimir el valor de un campo opcional
if (value.fields().contains("MyOptionalField"))
qDebug() << value.fields().value("MyField").value<QOpcUaQualifiedName>();
// Obtener una estructura anidada para un campo
const auto unionMember = value.fields().value("MyUnionMember").value<QOpcUaGenericStructValue>();
// Imprimir el campo especificado
if (unionMember.fields().contains("UnionMember1"))
qDebug() << unionMember.fields().value("UnionMember1").toInt();
else if (unionMember.fields().contains("UnionMember2"))
qDebug() << unionMember.fields().value("UnionMember2").toDouble();
sino
qDebug() << "Empty union";Documentación sobre funciones de miembro
QOpcUaGenericStructValue::QOpcUaGenericStructValue()
Crea un valor de estructura genérica.
QOpcUaGenericStructValue::QOpcUaGenericStructValue(const QString &typeName, const QString &typeId, const QOpcUaStructureDefinition &definition)
Crea un valor de estructura genérico a partir de typeName, typeId y definition.
QOpcUaGenericStructValue::QOpcUaGenericStructValue(const QString &typeName, const QString &typeId, const QOpcUaStructureDefinition &definition, const QHash<QString, QVariant> &fields)
Crea un valor de estructura genérico a partir de typeName, typeId, definition y fields.
QOpcUaGenericStructValue::QOpcUaGenericStructValue(const QOpcUaGenericStructValue &other)
Crea un valor de estructura genérico a partir de other.
[constexpr noexcept default] QOpcUaGenericStructValue::QOpcUaGenericStructValue(QOpcUaGenericStructValue &&other)
Crea mediante «move» un nuevo valor de estructura genérica a partir de other.
Nota: El objeto del que se ha realizado el movimiento, ` other `, queda en un estado parcialmente formado, en el que las únicas operaciones válidas son la destrucción y la asignación de un nuevo valor.
[noexcept] QOpcUaGenericStructValue::~QOpcUaGenericStructValue()
Destruye este objeto de valor de estructura genérica.
QHash<QString, QVariant> QOpcUaGenericStructValue::fields() const
Devuelve los campos de este valor de estructura genérica.
Véase también setFields().
QHash<QString, QVariant> &QOpcUaGenericStructValue::fieldsRef()
Devuelve una referencia a los campos de este valor de estructura genérica.
void QOpcUaGenericStructValue::setFields(const QHash<QString, QVariant> &fields)
Establece los campos de este valor de estructura genérica en fields.
Véase también fields().
void QOpcUaGenericStructValue::setStructureDefinition(const QOpcUaStructureDefinition &structureDefinition)
Establece la definición de la estructura para este valor de estructura genérica en structureDefinition.
Véase también structureDefinition().
void QOpcUaGenericStructValue::setTypeId(const QString &typeId)
Establece el identificador del nodo de tipo de este valor de estructura genérica en « typeId ».
Véase también typeId().
void QOpcUaGenericStructValue::setTypeName(const QString &typeName)
Establece el nombre del tipo de este valor de estructura genérica como « typeName ».
Véase también ` typeName()`.
QOpcUaStructureDefinition QOpcUaGenericStructValue::structureDefinition() const
Devuelve la definición de la estructura correspondiente a este valor de estructura genérica.
Véase también ` setStructureDefinition()`.
[noexcept] void QOpcUaGenericStructValue::swap(QOpcUaGenericStructValue &other)
Intercambia el objeto de valor de estructura genérica other por este objeto de valor de estructura genérica. Esta operación es muy rápida y nunca falla.
QString QOpcUaGenericStructValue::toString() const
Devuelve una representación en forma de cadena de este valor de estructura genérica.
QString QOpcUaGenericStructValue::typeId() const
Devuelve el identificador del nodo de tipo correspondiente a este valor de estructura genérica.
Véase también setTypeId().
QString QOpcUaGenericStructValue::typeName() const
Devuelve el nombre del tipo de este valor de estructura genérica.
Véase también setTypeName().
QOpcUaGenericStructValue::operator QVariant() const
Devuelve un objeto de tipo ` QVariant ` que contiene este valor de estructura genérica.
[noexcept] QOpcUaGenericStructValue &QOpcUaGenericStructValue::operator=(QOpcUaGenericStructValue &&other)
La operación «move-assigns» asigna other a esta instancia de QOpcUaGenericStructValue.
Nota: El objeto del que se ha realizado el movimiento, other, pasa a un estado parcialmente formado, en el que las únicas operaciones válidas son la destrucción y la asignación de un nuevo valor.
QOpcUaGenericStructValue &QOpcUaGenericStructValue::operator=(const QOpcUaGenericStructValue &rhs)
Establece el valor de « rhs » en esta estructura genérica «value».
Elementos no miembros relacionados
[noexcept] bool operator!=(const QOpcUaGenericStructValue &lhs, const QOpcUaGenericStructValue &rhs)
Devuelve « true » si « lhs » no es igual a « rhs ».
QDebug operator<<(QDebug debug, const QOpcUaGenericStructValue &s)
Muestra la representación en forma de cadena de ` s ` en ` debug`.
[noexcept] bool operator==(const QOpcUaGenericStructValue &lhs, const QOpcUaGenericStructValue &rhs)
Devuelve « true » si « lhs » es igual a « rhs ».
© 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.