QRemoteObjectHostBase 类

The QRemoteObjectHostBase class provides base functionality common to Host and RegistryHost 类。 更多...

头: #include <QRemoteObjectHostBase>
qmake: QT += remoteobjects
继承: QRemoteObjectNode
继承者: QRemoteObjectHost and QRemoteObjectRegistryHost

公共函数

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)

重实现公共函数

virtual void setName (const QString & name ) override

额外继承成员

详细描述

The QRemoteObjectHostBase class provides base functionality common to Host and RegistryHost 类。

QRemoteObjectHostBase is a base class that cannot be instantiated directly. It provides the enableRemoting and disableRemoting 功能共享通过所有主机节点 ( Host and RegistryHost ) 及逻辑要求暴露 对象在远程对象网络。

成员函数文档编制

bool QRemoteObjectHostBase:: disableRemoting ( QObject * remoteObject )

禁用远程访问 QObject remoteObject 。返回 false 若当前节点是客户端节点,或者若 remoteObject 未注册,和返回 true 若 Source (源) 对象成功禁用远程。

警告: 此对象的复本将不再有效,在调用此方法后。

另请参阅 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.

返回 false 若当前节点是客户端节点,或者若 QObject 已注册为远程,和 true 若成功启用远程为 QObject .

另请参阅 disableRemoting ().

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

使主机节点能够动态提供远程访问 QObject object 。连接到托管此对象的节点的客户端节点,可以获得此源的复本。

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 那么 QObject::objectName () is used.

返回 false 若当前节点是客户端节点,或者若 QObject 已注册为远程,和 true 若成功启用远程为动态 QObject .

另请参阅 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 and 复本 , 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.

返回 false 若当前节点是客户端节点,或者若 QObject 已注册为远程,和 true 若成功启用远程为 QAbstractItemModel .

另请参阅 disableRemoting ().

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

重实现自 QRemoteObjectNode::setName ().

类似于 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.