PySide6.QtRemoteObjects.QRemoteObjectNode

class QRemoteObjectNode

A node on a Qt Remote Objects network. More

Inheritance diagram of PySide6.QtRemoteObjects.QRemoteObjectNode

Inherited by: QRemoteObjectHostBase, QRemoteObjectRegistryHost, QRemoteObjectHost

Synopsis

Properties

Methods

Virtual methods

Signals

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

Detailed Description

The QRemoteObjectNode class provides an entry point to a QtRemoteObjects network. A network can be as simple as two nodes, or an arbitrarily complex set of processes and devices.

A QRemoteObjectNode does not have a url that other nodes can connect to, and thus is able to acquire replicas only. It is not able to share source objects (only QRemoteObjectHost and QRemoteObjectRegistryHost Nodes can share).

Nodes may connect to each other directly using connectToNode , or they can use the QRemoteObjectRegistry to simplify connections.

The QRemoteObjectRegistry is a special replica available to every node that connects to the Registry Url. It knows how to connect to every QRemoteObjectSource object on the network.

class ErrorCode

This enum type specifies the various error codes associated with QRemoteObjectNode errors:

Constant

Description

QRemoteObjectNode.NoError

No error.

QRemoteObjectNode.RegistryNotAcquired

The registry could not be acquired.

QRemoteObjectNode.RegistryAlreadyHosted

The registry is already defined and hosting Sources.

QRemoteObjectNode.NodeIsNoServer

The given QRemoteObjectNode is not a host node.

QRemoteObjectNode.ServerAlreadyCreated

The host node has already been initialized.

QRemoteObjectNode.UnintendedRegistryHosting

An attempt was made to create a host QRemoteObjectNode and connect to itself as the registry.

QRemoteObjectNode.OperationNotValidOnClientNode

The attempted operation is not valid on a client QRemoteObjectNode .

QRemoteObjectNode.SourceNotRegistered

The given QRemoteObjectSource is not registered on this node.

QRemoteObjectNode.MissingObjectName

The given QObject does not have objectName() set.

QRemoteObjectNode.HostUrlInvalid

The given url has an invalid or unrecognized scheme.

QRemoteObjectNode.ProtocolMismatch

The client and the server have different protocol versions.

QRemoteObjectNode.ListenFailed

Can’t listen on the specified host port.

QRemoteObjectNode.SocketAccessError

The client isn’t allowed to connect to the server. Ensure that setLocalServerOptions is set appropriately.

Note

Properties can be used directly when from __feature__ import true_property is used or via accessor functions otherwise.

property heartbeatIntervalᅟ: int

This property holds Heartbeat interval in ms..

The heartbeat (only helpful for socket connections) will periodically send a message to connected nodes to detect whether the connection was disrupted. Qt Remote Objects will try to reconnect automatically if it detects a dropped connection. This function can help with that detection since the client will only detect that the server is unavailable when it tries to send data.

A value of 0 (the default) will disable the heartbeat.

Access functions:
property persistedStoreᅟ: QRemoteObjectAbstractPersistedStore

This property holds Allows setting a QRemoteObjectAbstractPersistedStore instance for the node..

Allows replica PROP members with the PERSISTED trait to save their current value when the replica is deleted and restore a stored value the next time the replica is started.

Requires a QRemoteObjectAbstractPersistedStore class implementation to control where and how persistence is handled.

Access functions:
property registryUrlᅟ: QUrl

This property holds The address of the Registry used by this node..

This is an empty QUrl if there is no registry in use.

Access functions:
__init__([parent=None])
Parameters:

parentQObject

Default constructor for QRemoteObjectNode with the given parent. A Node constructed in this manner can not be connected to, and thus can not expose Source objects on the network. It also will not include a QRemoteObjectRegistry , unless set manually using setRegistryUrl .

__init__(registryAddress[, parent=None])
Parameters:

QRemoteObjectNode connected to a { QRemoteObjectRegistry } {Registry}. A Node constructed in this manner can not be connected to, and thus can not expose Source objects on the network. Finding and connecting to other (Host) Nodes is handled by the QRemoteObjectRegistry specified by registryAddress.

acquireDynamic(name)
Parameters:

name – str

Return type:

QRemoteObjectDynamicReplica

Returns a QRemoteObjectDynamicReplica of the Source name.

acquireModel(name[, action=QtRemoteObjects.FetchRootSize[, rolesHint={}]])
Parameters:
  • name – str

  • actionInitialAction

  • rolesHint – .list of int

Return type:

QAbstractItemModelReplica

Returns a pointer to a Replica which is specifically derived from QAbstractItemModel. The name provided must match the name used with the matching enableRemoting that put the Model on the network. action specifies whether the model should fetch data before the initialized signal is emitted. If it’s set to PrefetchData , then the data for roles in the rolesHint will be prefetched. If rolesHint is empty, then the data for all the roles exposed by Source will be prefetched.

The returned model will be empty until it is initialized with the Source .

addClientSideConnection(ioDevice)
Parameters:

ioDeviceQIODevice

In order to acquire() Replica objects over External QIODevices , Qt Remote Objects needs access to the communications channel (a QIODevice) between the respective nodes. It is the addClientSideConnection() call that enables this, taking the ioDevice as input. Any acquire() call made without calling addClientSideConnection will still work, but the Node will not be able to initialize the Replica without being provided the connection to the Host node.

connectToNode(address)
Parameters:

addressQUrl

Return type:

bool

Connects a client node to the host node at address.

Connections will remain valid until the host node is deleted or no longer accessible over a network.

Once a client is connected to a host, valid Replicas can then be acquired if the corresponding Source is being remoted.

Return true on success, false otherwise (usually an unrecognized url, or connecting to already connected address).

error(errorCode)
Parameters:

errorCodeErrorCode

heartbeatInterval()
Return type:

int

Getter of property heartbeatIntervalᅟ .

heartbeatIntervalChanged(heartbeatInterval)
Parameters:

heartbeatInterval – int

Notification signal of property heartbeatIntervalᅟ .

instances(typeName)
Parameters:

typeName – str

Return type:

list of strings

This function overloads instances() .

This convenience function provides the same result as the templated version, but takes the name of the Source class as a parameter (typeName) rather than deriving it from the class type.

lastError()
Return type:

ErrorCode

Returns the last error set.

persistedStore()
Return type:

QRemoteObjectAbstractPersistedStore

Getter of property persistedStoreᅟ .

registry()
Return type:

QRemoteObjectRegistry

Returns a pointer to the Node’s QRemoteObjectRegistry , if the Node is using the Registry feature; otherwise it returns None.

registryUrl()
Return type:

QUrl

See also

setRegistryUrl()

Getter of property registryUrlᅟ .

remoteObjectAdded(loc)
Parameters:

loc – .std.pairQString,QRemoteObjectSourceLocationInfo

This signal is emitted whenever a new Source object is added to the Registry. The signal will not be emitted if there is no Registry set (i.e., Sources over connections made via connectToNode directly). The loc parameter contains the information about the added Source, including name, type and the QUrl of the hosting Node.

remoteObjectRemoved(loc)
Parameters:

loc – .std.pairQString,QRemoteObjectSourceLocationInfo

This signal is emitted whenever a known Source object is removed from the Registry. The signal will not be emitted if there is no Registry set (i.e., Sources over connections made via connectToNode directly). The loc parameter contains the information about the removed Source, including name, type and the QUrl of the hosting Node.

setHeartbeatInterval(interval)
Parameters:

interval – int

Setter of property heartbeatIntervalᅟ .

setName(name)
Parameters:

name – str

Sets name as the internal name for this Node. This is then output as part of the logging (if enabled). This is primarily useful if you merge log data from multiple nodes.

setPersistedStore(persistedStore)
Parameters:

persistedStoreQRemoteObjectAbstractPersistedStore

See also

persistedStore()

Setter of property persistedStoreᅟ .

setRegistryUrl(registryAddress)
Parameters:

registryAddressQUrl

Return type:

bool

See also

registryUrl()

waitForRegistry([timeout=30000])
Parameters:

timeout – int

Return type:

bool

Blocks until this Node’s Registry is initialized or timeout (in milliseconds) expires. Returns true if the Registry is successfully initialized upon return, or false otherwise.