In questa pagina

QOpcUaGenericStructValue Class

Contiene il valore di un tipo strutturato OPC UA generico. Maggiori informazioni...

Intestazione: #include <QOpcUaGenericStructValue>
CMake: find_package(Qt6 REQUIRED COMPONENTS OpcUa)
target_link_libraries(mytarget PRIVATE Qt6::OpcUa)
qmake: QT += opcua
A partire da: Qt 6.7

Funzioni pubbliche

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)
bool operator!=(const QOpcUaGenericStructValue &lhs, const QOpcUaGenericStructValue &rhs)
QDebug operator<<(QDebug debug, const QOpcUaGenericStructValue &s)
bool operator==(const QOpcUaGenericStructValue &lhs, const QOpcUaGenericStructValue &rhs)

Descrizione dettagliata

Questa classe contiene un valore di struttura generico OPC UA costituito da campi denominati con i relativi valori, che possono essere tipi incorporati o loro sottotipi, nonché altre strutture generiche annidate. Sono incluse anche alcune meta-informazioni, quali l'ID del tipo e la definizione della struttura del tipo contenuto in un oggetto di questa classe.

Viene utilizzata come tipo di ritorno per il risultato della decodifica e come tipo di input per il metodo di codifica di ` QOpcUaGenericStructHandler`.

Per una struttura con campi opzionali, nell’elenco ` fields() ` sono inclusi solo i campi specificati. Per omettere un campo opzionale durante la codifica, esso non deve comparire nell’elenco ` fields()`. Per le struct derivate dal tipo Union, deve essere specificato solo uno dei campi. L’unica voce nell’elenco fields() di un tipo decodificato determina quale campo (se presente) della definizione del tipo è stato specificato.

Esempio:

// Decodifica un oggetto di estensione
QOpcUaGenericStructValue value = decoder.decode(extensionObject, success);

// Visualizza il valore di un campo obbligatorio
qDebug() << value.fields().value("MyField").value<QOpcUaLocalizedText>();

// Visualizza il valore di un campo opzionale
if (value.fields().contains("MyOptionalField"))
    qDebug() << value.fields().value("MyField").value<QOpcUaQualifiedName>();

// Recupera una struttura annidata per un campo
const auto unionMember = value.fields().value("MyUnionMember").value<QOpcUaGenericStructValue>();

// Visualizza il campo specificato
if (unionMember.fields().contains("UnionMember1"))
    qDebug() << unionMember.fields().value("UnionMember1").toInt();
else if (unionMember.fields().contains("UnionMember2"))
    qDebug() << unionMember.fields().value("UnionMember2").toDouble();
altrimenti
    qDebug() << "Empty union";

Documentazione sulle funzioni membro

QOpcUaGenericStructValue::QOpcUaGenericStructValue()

Crea un valore di struttura generico.

QOpcUaGenericStructValue::QOpcUaGenericStructValue(const QString &typeName, const QString &typeId, const QOpcUaStructureDefinition &definition)

Crea un valore di struttura generico a partire da typeName, typeId e definition.

QOpcUaGenericStructValue::QOpcUaGenericStructValue(const QString &typeName, const QString &typeId, const QOpcUaStructureDefinition &definition, const QHash<QString, QVariant> &fields)

Crea un valore di struttura generico a partire da typeName, typeId, definition e fields.

QOpcUaGenericStructValue::QOpcUaGenericStructValue(const QOpcUaGenericStructValue &other)

Crea un valore di struttura generico a partire da other.

[constexpr noexcept default] QOpcUaGenericStructValue::QOpcUaGenericStructValue(QOpcUaGenericStructValue &&other)

Crea una nuova struttura generica tramite move da other.

Nota: l'oggetto da cui è stato effettuato lo spostamento other viene posto in uno stato parzialmente formato, in cui le uniche operazioni valide sono la distruzione e l'assegnazione di un nuovo valore.

[noexcept] QOpcUaGenericStructValue::~QOpcUaGenericStructValue()

Elimina questo oggetto valore di tipo struct generico.

QHash<QString, QVariant> QOpcUaGenericStructValue::fields() const

Restituisce i campi di questo valore di struttura generica.

Vedi anche setFields().

QHash<QString, QVariant> &QOpcUaGenericStructValue::fieldsRef()

Restituisce un riferimento ai campi di questo valore di struttura generica.

void QOpcUaGenericStructValue::setFields(const QHash<QString, QVariant> &fields)

Imposta i campi di questa struttura generica su fields.

Vedi anche ` fields()`.

void QOpcUaGenericStructValue::setStructureDefinition(const QOpcUaStructureDefinition &structureDefinition)

Imposta la definizione della struttura per questo valore di tipo generico su structureDefinition.

Vedi anche ` structureDefinition()`.

void QOpcUaGenericStructValue::setTypeId(const QString &typeId)

Imposta l'ID del nodo di tipo per questo valore di struttura generica su typeId.

Vedi anche typeId().

void QOpcUaGenericStructValue::setTypeName(const QString &typeName)

Imposta il nome del tipo per questo valore di struttura generica su “ typeName ”.

Vedi anche ` typeName()`.

QOpcUaStructureDefinition QOpcUaGenericStructValue::structureDefinition() const

Restituisce la definizione della struttura corrispondente a questo valore di tipo generico.

Vedi anche setStructureDefinition().

[noexcept] void QOpcUaGenericStructValue::swap(QOpcUaGenericStructValue &other)

Sostituisce l'oggetto valore della struttura generica other con questo oggetto valore della struttura generica. Questa operazione è molto veloce e non fallisce mai.

QString QOpcUaGenericStructValue::toString() const

Restituisce una rappresentazione sotto forma di stringa per questo valore della struttura generica.

QString QOpcUaGenericStructValue::typeId() const

Restituisce l'ID del nodo del tipo corrispondente a questo valore di struttura generica.

Vedi anche setTypeId().

QString QOpcUaGenericStructValue::typeName() const

Restituisce il nome del tipo corrispondente a questo valore della struttura generica.

Vedi anche setTypeName().

QOpcUaGenericStructValue::operator QVariant() const

Restituisce un oggetto di tipo ` QVariant ` contenente questo valore di struttura generica.

[noexcept] QOpcUaGenericStructValue &QOpcUaGenericStructValue::operator=(QOpcUaGenericStructValue &&other)

L'operazione "move-assign" assegna other a questa istanza di QOpcUaGenericStructValue.

Nota: l'oggetto da cui è stato effettuato lo spostamento, other, viene posto in uno stato parzialmente formato, in cui le uniche operazioni valide sono la distruzione e l'assegnazione di un nuovo valore.

QOpcUaGenericStructValue &QOpcUaGenericStructValue::operator=(const QOpcUaGenericStructValue &rhs)

Imposta il valore di “ rhs ” in questa struttura generica “value”.

Elementi non membri correlati

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

Restituisce " true " se " lhs " non è uguale a " rhs".

QDebug operator<<(QDebug debug, const QOpcUaGenericStructValue &s)

Visualizza la rappresentazione stringa di ` s ` in ` debug`.

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

Restituisce " true " se " lhs " è uguale 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.