QRemoteObjectHostBase Class

The QRemoteObjectHostBase class provides base functionality common to Host and RegistryHost classes. More...

Header: #include <QRemoteObjectHostBase>
qmake: QT += remoteobjects
Inherits: QRemoteObjectNode
Inherited By:

QRemoteObjectHost and QRemoteObjectRegistryHost

Public Functions

bool disableRemoting(QObject *remoteObject)
bool enableRemoting(ObjectType *object)
bool enableRemoting(QObject *object, const QString &name = QString())
bool enableRemoting(QAbstractItemModel *model, const QString &name, const QVector<int> roles, QItemSelectionModel *selectionModel = nullptr)

Reimplemented Public Functions

virtual void setName(const QString &name) override

Additional Inherited Members

Detailed Description

The QRemoteObjectHostBase class provides base functionality common to Host and RegistryHost classes.

QRemoteObjectHostBase is a base class that cannot be instantiated directly. It provides the enableRemoting and disableRemoting functionality shared by all host nodes (Host and RegistryHost) as well as the logic required to expose Source objects on the Remote Objects network.

Member Function Documentation

bool QRemoteObjectHostBase::disableRemoting(QObject *remoteObject)

Disables remote access for the QObject remoteObject. Returns false if the current node is a client node or if the remoteObject is not registered, and returns true if remoting is successfully disabled for the Source object.

Warning: Replicas of this object will no longer be valid after calling this method.

See also enableRemoting().

bool QRemoteObjectHostBase::enableRemoting(ObjectType *object)

This templated function overload enables a host node to provide remote access to a QObject object with a specified (and compile-time checked) interface. Client nodes connected to the node hosting this object may obtain Replicas of this Source.

This is best illustrated by example:

#include "rep_TimeModel_source.h"
MinuteTimer timer;
hostNode.enableRemoting<MinuteTimerSourceAPI>(&timer);

Here the MinuteTimerSourceAPI is the set of Signals/Slots/Properties defined by the TimeModel.rep file. Compile time checks are made to verify the input QObject can expose the requested API, it will fail to compile otherwise. This allows a subset of object 's interface to be exposed, and allows the types of conversions supported by Signal/Slot connections.

Returns false if the current node is a client node, or if the QObject is already registered to be remoted, and true if remoting is successfully enabled for the QObject.

See also disableRemoting().

bool QRemoteObjectHostBase::enableRemoting(QObject *object, const QString &name = QString())

Enables a host node to dynamically provide remote access to the QObject object. Client nodes connected to the node hosting this object may obtain Replicas of this Source.

The name defines the lookup-name under which the QObject can be acquired using QRemoteObjectNode::acquire() . If not explicitly set then the name given in the QCLASSINFO_REMOTEOBJECT_TYPE will be used. If no such macro was defined for the QObject then the QObject::objectName() is used.

Returns false if the current node is a client node, or if the QObject is already registered to be remoted, and true if remoting is successfully enabled for the dynamic QObject.

See also disableRemoting().

bool QRemoteObjectHostBase::enableRemoting(QAbstractItemModel *model, const QString &name, const QVector<int> roles, QItemSelectionModel *selectionModel = nullptr)

This overload of enableRemoting() is specific to QAbstractItemModel types (or any type derived from QAbstractItemModel). This is useful if you want to have a model and the HMI for the model in different processes.

The three required parameters are the model itself, the name by which to lookup the model, and the roles that should be exposed on the Replica side. If you want to synchronize selection between Source and Replica, the optional selectionModel parameter can be used. This is only recommended when using a single Replica.

Behind the scenes, Qt Remote Objects batches data() lookups and prefetches data when possible to make the model interaction as responsive as possible.

Returns false if the current node is a client node, or if the QObject is already registered to be remoted, and true if remoting is successfully enabled for the QAbstractItemModel.

See also disableRemoting().

[override virtual] void QRemoteObjectHostBase::setName(const QString &name)

Reimplemented from QRemoteObjectNode::setName().

Similar to QObject::setObjectName() (which this method calls), but this version also applies the name to internal classes as well, which are used in some of the debugging output.

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