MethodNode QML Type
在服务器上调用一个方法。更多...
| Import Statement: | import QtOpcUa |
| Since: | QtOpcUa 5.12 |
| Inherits: | |
| Status: | Deprecated since 6.9 |
自 QtOpcUa 6.9 起,此类型已被废弃。我们强烈建议不要在新代码中使用它。
属性
- inputArguments : list<MethodArgument>
- objectNodeId : OpcUaNode
- outputArguments : list<var>
- resultStatus : Status
- type : QOpcUa::Types
方法
- void callMethod()
详细说明
此 QML 元素支持调用服务器上的方法节点。必须通过objectNodeId 属性指定目标对象节点的 ID。
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>
在服务器端调用该方法时使用的参数。
本示例演示了如何调用一个带有两个 double 类型参数的方法。
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]
返回方法调用的结果。根据输出参数的不同,该列表可能包含零个或多个值。必须单独检查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])
}另请参阅 callMethod 和resultStatus 。
resultStatus : Status [read-only]
上次方法调用的状态。必须检查此属性以确定方法调用是否成功。
另请参阅 Status 。
type : QOpcUa::Types
设置服务器所期望的参数类型。调用该方法时,`variant` 值将被转换为该类型。该类型必须与服务器端的方法完全匹配,否则方法调用将失败。
另请参阅 MethodNode::callMethod 。
方法文档
void callMethod()
在已连接的服务器上调用该方法。
© 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.