QOpcUaVariant Class

The OPC UA Variant. More...

Header: #include <QOpcUaVariant>
CMake: find_package(Qt6 REQUIRED COMPONENTS OpcUa)
target_link_libraries(mytarget PRIVATE Qt6::OpcUa)
qmake: QT += opcua
Since: Qt 6.7

Public Types

enum class ValueType { Unknown, Boolean, SByte, Byte, Int16, …, DiagnosticInfo }

Public Functions

QOpcUaVariant()
QOpcUaVariant(QOpcUaVariant::ValueType type, const QVariant &value)
QOpcUaVariant(QOpcUaVariant::ValueType type, const QVariant &value, const QList<qint32> arrayDimensions)
QOpcUaVariant(const QOpcUaVariant &other)
QOpcUaVariant(QOpcUaVariant &&other)
~QOpcUaVariant()
QList<qint32> arrayDimensions() const
bool isArray() const
void setArrayDimensions(const QList<qint32> &arrayDimensions)
void setValue(QOpcUaVariant::ValueType type, const QVariant &value)
void setValue(QOpcUaVariant::ValueType type, const QVariant &value, const QList<qint32> &arrayDimensions)
void swap(QOpcUaVariant &other)
QOpcUaVariant::ValueType type() const
QVariant value() const
QVariant operator QVariant() const
QOpcUaVariant &operator=(QOpcUaVariant &&other)
QOpcUaVariant &operator=(const QOpcUaVariant &rhs)
bool operator!=(const QOpcUaVariant &lhs, const QOpcUaVariant &rhs)
bool operator==(const QOpcUaVariant &lhs, const QOpcUaVariant &rhs)

Detailed Description

The OPC UA variant is an union of all built-in OPC UA types and also contains information about the array dimensions associated with the value. This class is currently only supported by QOpcUaBinaryDataEncoding and QOpcUaGenericStructHandler.

Member Type Documentation

enum class QOpcUaVariant::ValueType

This enum contains the possible value types of an OPC UA variant.

ConstantValueDescription
QOpcUaVariant::ValueType::Unknown0 
QOpcUaVariant::ValueType::Boolean1 
QOpcUaVariant::ValueType::SByte2 
QOpcUaVariant::ValueType::Byte3 
QOpcUaVariant::ValueType::Int164 
QOpcUaVariant::ValueType::UInt165 
QOpcUaVariant::ValueType::Int326 
QOpcUaVariant::ValueType::UInt327,
QOpcUaVariant::ValueType::Int648 
QOpcUaVariant::ValueType::UInt649 
QOpcUaVariant::ValueType::Float10 
QOpcUaVariant::ValueType::Double11 
QOpcUaVariant::ValueType::String12 
QOpcUaVariant::ValueType::DateTime13 
QOpcUaVariant::ValueType::Guid14 
QOpcUaVariant::ValueType::ByteString15 
QOpcUaVariant::ValueType::XmlElement16 
QOpcUaVariant::ValueType::NodeId17 
QOpcUaVariant::ValueType::ExpandedNodeId18 
QOpcUaVariant::ValueType::StatusCode19 
QOpcUaVariant::ValueType::QualifiedName20 
QOpcUaVariant::ValueType::LocalizedText21 
QOpcUaVariant::ValueType::ExtensionObject22 
QOpcUaVariant::ValueType::DataValue23 
QOpcUaVariant::ValueType::Variant24 
QOpcUaVariant::ValueType::DiagnosticInfo25 

Member Function Documentation

QOpcUaVariant::QOpcUaVariant()

Default constructs a new OPC UA variant.

QOpcUaVariant::QOpcUaVariant(QOpcUaVariant::ValueType type, const QVariant &value)

Constructs a new OPC UA variant of type type with value value.

Scalar values must be passed as a QVariant containing a value of type. Array values must be passed as a QVariant containing a QList of type.

QOpcUaVariant::QOpcUaVariant(QOpcUaVariant::ValueType type, const QVariant &value, const QList<qint32> arrayDimensions)

Constructs a new OPC UA variant of type type with value value and array dimensions arrayDimensions.

Scalar values must be passed as a QVariant containing a value of type. Array values must be passed as a QVariant containing a QList of type.

QOpcUaVariant::QOpcUaVariant(const QOpcUaVariant &other)

Constructs a new OPC UA variant from other.

[noexcept] QOpcUaVariant::QOpcUaVariant(QOpcUaVariant &&other)

Move-constructs a new OPC UA variant from other.

Note: The moved-from object other is placed in a partially-formed state, in which the only valid operations are destruction and assignment of a new value.

[noexcept] QOpcUaVariant::~QOpcUaVariant()

Destroys this OPC UA variant.

QList<qint32> QOpcUaVariant::arrayDimensions() const

Returns the array dimensions of this OPC UA variant.

See also setArrayDimensions().

bool QOpcUaVariant::isArray() const

Returns true if this OPC UA variant contains an array value.

void QOpcUaVariant::setArrayDimensions(const QList<qint32> &arrayDimensions)

Sets the array dimensions to arrayDimensions.

See also arrayDimensions().

void QOpcUaVariant::setValue(QOpcUaVariant::ValueType type, const QVariant &value)

Sets the value of this OPC UA variant to value and the type to type.

Scalar values must be passed as a QVariant containing a value of type. Array values must be passed as a QVariant containing a QList of type.

See also value().

void QOpcUaVariant::setValue(QOpcUaVariant::ValueType type, const QVariant &value, const QList<qint32> &arrayDimensions)

Sets the value of this OPC UA variant to value, the type to type and the array dimensions to arrayDimensions.

Scalar values must be passed as a QVariant containing a value of type. Array values must be passed as a QVariant containing a QList of type.

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

Swaps enum definition object other with this OPC UA variant object. This operation is very fast and never fails.

QOpcUaVariant::ValueType QOpcUaVariant::type() const

Returns the value type of this OPC UA variant.

QVariant QOpcUaVariant::value() const

Returns the value of this OPC UA variant.

See also setValue().

QVariant QOpcUaVariant::operator QVariant() const

Returns a QVariant containing this OPC UA variant.

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

Move-assigns other to this QOpcUaVariant instance.

Note: The moved-from object other is placed in a partially-formed state, in which the only valid operations are destruction and assignment of a new value.

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

Sets the values from rhs in this OPC UA variant.

Related Non-Members

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

Returns true if lhs is not equal to rhs.

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

Returns true if lhs is equal to rhs.