QOpcUaClient Class

QOpcUaClient allows interaction with an OPC UA server. More...

Header: #include <QOpcUaClient>
qmake: QT += opcua
Inherits: QObject

Public Types

enum ClientError { NoError, InvalidUrl, SecureConnectionError, AccessDenied, ConnectionError, UnknownError }
enum ClientState { Disconnected, Connecting, Connected, Closing }


  • error : const ClientError
  • state : const ClientState
  • 1 property inherited from QObject

Public Functions

QString backend() const
void connectToEndpoint(const QUrl &url)
void disconnectFromEndpoint()
ClientError error() const
bool isSecureConnectionSupported() const
QOpcUaNode *node(const QString &nodeId)
void secureConnectToEndpoint(const QUrl &url)
ClientState state() const
QUrl url() const
  • 32 public functions inherited from QObject


void connected()
void disconnected()
void errorChanged(QOpcUaClient::ClientError error)
void stateChanged(QOpcUaClient::ClientState state)

Additional Inherited Members

  • 1 public slot inherited from QObject
  • 1 public variable inherited from QObject
  • 10 static public members inherited from QObject
  • 9 protected functions inherited from QObject
  • 2 protected variables inherited from QObject

Detailed Description

QOpcUaClient allows interaction with an OPC UA server.


QOpcUaClient implements basic client capabilities to communicate with OPC UA enabled devices and applications. This includes connecting, disconnecting and getting QOpcUaNode objects for a node on the server.

Addressing Nodes

For an introduction to nodes and node ids, see QOpcUaNode.

Member Type Documentation

enum QOpcUaClient::ClientError

This enum type specifies the current error state of the client.

QOpcUaClient::NoError0No error occurred.
QOpcUaClient::InvalidUrl1The url to connect to has been wrongly specified or a connection to this url failed.
QOpcUaClient::SecureConnectionError2An attempt to connect to a server with a secure connection failed.
QOpcUaClient::AccessDenied3An attempt to connect to a server using username/password failed due to wrong credentials.
QOpcUaClient::ConnectionError4An error occurred with the connection.
QOpcUaClient::UnknownError5An unknown error occurred.

enum QOpcUaClient::ClientState

This enum type specifies the connection state of the client.

QOpcUaClient::Disconnected0The client is not connected to a server.
QOpcUaClient::Connecting1The client is currently connecting to a server.
QOpcUaClient::Connected2The client is connected to a server.
QOpcUaClient::Closing3The client has been connected and requests a disconnect from the server.

Property Documentation

error : const ClientError

Specifies the current error state of the client.

Access functions:

ClientError error() const

Notifier signal:

void errorChanged(QOpcUaClient::ClientError error)

state : const ClientState

Specifies the current connection state of the client.

Access functions:

ClientState state() const

Notifier signal:

void stateChanged(QOpcUaClient::ClientState state)

Member Function Documentation


Destroys the QOpcUaClient instance.

QString QOpcUaClient::backend() const

Returns the name of the backend used by this instance of QOpcUaClient, e.g. "freeopcua".

void QOpcUaClient::connectToEndpoint(const QUrl &url)

Connects to the OPC UA endpoint given in url.

See also disconnectFromEndpoint().

[signal] void QOpcUaClient::connected()

This signal is emitted when a connection has been established.

void QOpcUaClient::disconnectFromEndpoint()

Disconnects from the server.

See also connectToEndpoint().

[signal] void QOpcUaClient::disconnected()

This signal is emitted when a connection has been closed following to a close request.

ClientError QOpcUaClient::error() const

Returns the current error state of the client.

Note: Getter function for property error.

bool QOpcUaClient::isSecureConnectionSupported() const

Returns true if the backend supports a connection over an encrypted channel.

See also secureConnectToEndpoint.

QOpcUaNode *QOpcUaClient::node(const QString &nodeId)

Returns a QOpcUaNode object associated with the OPC UA node identified by nodeId. The caller becomes owner of the node object.

If the client is not connected, nullptr is returned. The backends may also return nullptr for other error cases (for example for a malformed node id).

void QOpcUaClient::secureConnectToEndpoint(const QUrl &url)

Connects to an endpoint given by url using the highest security level supported by client and server. true is returned in case of success, false is returned when the connection fails. User name and password must be set on url before connectToEndpoint is called.

Warning: Currently not supported by any backend.

See also disconnectFromEndpoint().

QUrl QOpcUaClient::url() const

Returns the URL of the OPC UA server the client is currently connected to or was last connected to.

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