Qt Remote Objects

遠程對象概念

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) 會被轉發給真實對象 (稱為 Source 在 QtRO) 進行處理。更新 Source (either property changes or emitted signals) are forwarded to every 復本 .

A 復本 是輕量級代理對於 Source object, but one that supports the same connections and behavior of QObjects, which makes it as easy to use as any other QObject 由 QT 提供。一切都需要 復本 看起來像 Source 對象由 QtRO 在幕後處理。

注意,遠程對象的行為異於傳統 RPC (遠程過程調用) 實現。在 RPC,客戶端發齣請求並等待響應。在 RPC,服務器不會嚮客戶端推送任何東西,除非是響應請求。RPC 的設計是經常使不同客戶端彼此獨立 (例如:2 個客戶端可以嚮映射服務詢問方嚮並獲得不同結果)。雖然可能以 QtRO 實現這 (如 Source 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 許可 進一步瞭解細節。

指南

參考

Qt Remote Objects C++ 類 Qt Remote Objects QML 類型