Qt Remote Objects (QtRO) is an inter-process communication (IPC) module developed for Qt. The idea is to extend Qt's existing functionalities to enable an easy exchange of information between processes or computers.
One of the key features of Qt to enable this is the distinction between an object's API (defined by its properties, signals and slots) and the implementation of that API. The purpose of QtRO is to meet the expected API, even if the true QObject is in a different process. A slot called on a copy of an object (called a 复本 在 QtRO) 会被转发给真实对象 (称为 源 在 QtRO) 进行处理。更新 源 (either property changes or emitted signals) are forwarded to every 复本 .
A 复本 是轻量级代理对于 源 object, but one that supports the same connections and behavior of QObjects, which makes it as easy to use as any other QObject 由 QT 提供。一切都需要 复本 看起来像 源 对象由 QtRO 在幕后处理。
注意,远程对象的行为异于传统 RPC (远程过程调用) 实现。在 RPC,客户端发出请求并等待响应。在 RPC,服务器不会向客户端推送任何东西,除非是响应请求。RPC 的设计是经常使不同客户端彼此独立 (例如:2 个客户端可以向映射服务询问方向并获得不同结果)。虽然可能以 QtRO 实现这 (如 源 without properties, and slots that have return values), it is designed more to hide the fact that the processing is really remote. You let a node give you the 复本 而不是自己创建,可以使用状态信号 ( isReplicaValid() ),然后与对象交互就像采用任何其它 QObject 基类型。
要启用 Qt Remote Objects 在工程中,添加此指令到 C++ 文件:
#include <QtRemoteObjects>
要链接到 Qt Remote Objects 模块,添加此行到工程文件:
QT += remoteobjects
Qt Remote Objects 在商业许可下是可用的来自 Qt 公司 。此外,它是可用的根据 GNU LGPL (次一般公共许可) 第 3 版 ,或 GNU GPL (一般公共许可) 第 2 版 。见 Qt 许可 进一步了解细节。