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 ) 及邏輯要求暴露 Source 對象在遠程對象網絡。

成員函數文檔編製

bool QRemoteObjectHostBase:: disableRemoting ( QObject * remoteObject )

禁用遠程訪問 QObject remoteObject 。返迴 false 若當前節點是客戶端節點,或者若 remoteObject 未注冊,和返迴 true 若 Source (源) 對象成功禁用遠程。

警告: 此對象的復本將不再有效,在調用此方法後。

另請參閱 enableRemoting ().

bool QRemoteObjectHostBase:: enableRemoting ( ObjectType * object )

此模闆化函數重載使主機節點,能夠提供遠程訪問對 QObject object 采用指定 (和編譯時校驗) 接口。連接到托管此對象的節點的客戶端節點,可以獲得此 Source (源) 的 Replica (復本)。

闡明這的最佳範例:

#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 () 被使用。

返迴 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 Source 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.