MethodNode QML Type | Qt OPC UA 6.4.1

- Qt 6.4
- Qt OPC UA
- QML Types
- MethodNode
- Qt 6.4.1 Reference Documentation

# MethodNode QML Type

Calls a method on the server. More...

Import Statement: | import QtOpcUa
Since: | QtOpcUa 5.12
Inherits: | Node

- List of all members, including inherited members

## Properties

- inputArguments : list<MethodArgument>
- objectNodeId : OpcUaNode
- outputArguments : list<var>
- resultStatus : Status
- type : QOpcUa::Types

## Methods

- callMethod()

## Detailed Description

This QML element supports calling method nodes on a server. The target object node ID has to be specified by the objectNodeId property.

     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
      }

The actual function call can be triggered by a signal.

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

or by JavaScript

     myNode.callMethod()

## Property Documentation

inputArguments : list<MethodArgument>

Arguments to be used when calling the method on the server.

This example shows how to call a method with two double arguments.

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

See also callMethod.

objectNodeId : OpcUaNode

Determines the actual node on which the method is called. It can be a relative or absolute node Id.

[read-only] outputArguments : list<var>

Returns values from the method call. Depending on the output arguments, this list may contain zero or more values. The resultStatus has to be checked separately. In case the method call failed, the list will be empty.

     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])
     }

See also callMethod and resultStatus.

[read-only] resultStatus : Status

Status of the last method call. This property has to be checked to determine if the method call was successful.

See also Status.

type : QOpcUa::Types

Sets the type of the argument that is expected by the server. The value variant is converted to that type when calling the method. The type has to match the method on the server exactly, otherwise the method call will fail.

See also MethodNode::callMethod.

## Method Documentation

callMethod()

Calls the method on the connected server.