本页内容

QOpcUaErrorState Class

QOpcUaErrorState 允许对后端返回的错误状态进行排查和交互。更多内容...

标题: #include <QOpcUaErrorState>
CMake: find_package(Qt6 REQUIRED COMPONENTS OpcUa)
target_link_libraries(mytarget PRIVATE Qt6::OpcUa)
qmake: QT += opcua
自: QtOpcUa 5.13

公共类型

enum class ConnectionStep { Unknown, CertificateValidation, OpenSecureChannel, CreateSession, ActivateSession }

公共函数

QOpcUaErrorState()
QOpcUaErrorState(const QOpcUaErrorState &other)
QOpcUaErrorState::ConnectionStep connectionStep() const
QOpcUa::UaStatusCode errorCode() const
bool ignoreError() const
bool isClientSideError() const
void setClientSideError(bool clientSideError)
void setConnectionStep(QOpcUaErrorState::ConnectionStep step)
void setErrorCode(QOpcUa::UaStatusCode error)
void setIgnoreError(bool ignore = true)
QOpcUaErrorState &operator=(const QOpcUaErrorState &rhs)

详细说明

在您的代码中无需实例化此类。如果建立连接时发生错误,客户端将通过 `QOpcUaClient::connectError ` 触发错误状态。

错误可能由后端自身引起,也可能是服务器拒绝了连接。如果是本地后端发出的错误,可以通过调用函数setIgnoreError() 来忽略这些错误。

成员类型文档

enum class QOpcUaErrorState::ConnectionStep

指定在建立连接过程中的哪一步发生了错误。

常量值描述
QOpcUaErrorState::ConnectionStep::Unknown0x00连接步骤未知。
QOpcUaErrorState::ConnectionStep::CertificateValidation0x1错误发生在证书验证步骤中。
QOpcUaErrorState::ConnectionStep::OpenSecureChannel0x2打开安全通道时发生错误。
QOpcUaErrorState::ConnectionStep::CreateSession0x3建立会话时发生错误。
QOpcUaErrorState::ConnectionStep::ActivateSession0x4会话激活过程中发生错误。

成员函数文档

QOpcUaErrorState::QOpcUaErrorState()

默认情况下会构建一个未设置任何参数的错误状态。

QOpcUaErrorState::QOpcUaErrorState(const QOpcUaErrorState &other)

根据other 构建一个错误状态。

QOpcUaErrorState::ConnectionStep QOpcUaErrorState::connectionStep() const

返回发生错误的连接步骤。

另请参阅 setConnectionStep()。

QOpcUa::UaStatusCode QOpcUaErrorState::errorCode() const

返回发生错误时的 OPC UA 状态码。

另请参阅 setErrorCode()。

bool QOpcUaErrorState::ignoreError() const

返回该客户端错误是否应被忽略。

另请参阅 setIgnoreError()。

bool QOpcUaErrorState::isClientSideError() const

如果发生的错误是客户端错误,则返回该值。

void QOpcUaErrorState::setClientSideError(bool clientSideError)

如果发生的错误是客户端错误,则将该错误设置为clientSideError 。

另请参阅 isClientSideError()。

void QOpcUaErrorState::setConnectionStep(QOpcUaErrorState::ConnectionStep step)

将发生错误的连接步骤设置为step 。

另请参阅 connectionStep()。

void QOpcUaErrorState::setErrorCode(QOpcUa::UaStatusCode error)

将发生的错误的 OPC UA 状态码设置为error 。

另请参阅 errorCode()。

void QOpcUaErrorState::setIgnoreError(bool ignore = true)

将此客户端错误是否应被忽略的设置设为ignore 。

只有当该错误确实是客户端错误时,设置此标志才有效。

另请参阅 ignoreError()。

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

设置此错误状态下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.