MethodNode QML Type

调用服务器上的方法。更多

Import Statement: import QtOpcUa
Since: QtOpcUa 5.12
Inherits:

Node

Status: Deprecated since 6.9

自 QtOpcUa 6.9 起,该类型已被弃用。我们强烈建议不要在新代码中使用它。

属性

方法

详细说明

该 QML 元素支持在服务器上调用方法节点。目标对象节点 ID 必须由objectNodeId 属性指定。

import QtOpcUa as QtOpcUa

QtOpcUa.MethodNode {
    nodeId : QtOpcUa.NodeId {
        identifier: "s=Example.Method"
        ns: "Example Namespace"
    }
    objectNodeId : QtOpcUa.NodeId {
        identifier: "s=Example.Object"
        ns: "Example Namespace"
    }
    connection: myConnection
 }

实际函数调用可由信号触发。

Button {
      text: "Start"
      onClicked: myNode.callMethod
}

或 JavaScript

myNode.callMethod()

属性文档

inputArguments : list<MethodArgument>

在服务器上调用方法时使用的参数。

本示例展示了如何调用带有两个双参数的方法。

QtOpcUa.MethodNode {
    ...
    inputArguments: [
        QtOpcUa.MethodArgument {
            value: 3
            type: QtOpcUa.Constants.Double
        },
        QtOpcUa.MethodArgument {
            value: 4
            type: QtOpcUa.Constants.Double
        }
    ]
}

另请参见 callMethod


objectNodeId : OpcUaNode

确定调用方法的实际节点。它可以是相对或绝对节点 Id。


outputArguments : list<var> [read-only]

从方法调用中返回值。根据输出参数的不同,该列表可能包含 0 个或多个值。resultStatus 必须单独检查。如果方法调用失败,列表将为空。

if (node.status.isGood) {
    // print two arguments
    console.log("Number of return values:", node.outputArguments.length)
    console.log("Return value #1:", node.outputArguments[0])
    console.log("Return value #2:", node.outputArguments[1])
}

另请参阅 callMethodresultStatus


resultStatus : Status [read-only]

最后一次方法调用的状态。必须检查该属性,以确定方法调用是否成功。

另请参阅 Status


type : QOpcUa::Types

设置服务器期望的参数类型。在调用方法时,值变量将转换为该类型。该类型必须与服务器上的方法完全匹配,否则方法调用将失败。

另请参阅 MethodNode::callMethod


方法文档

callMethod()

调用已连接服务器上的方法。


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