Remote Object Interaction
远程对象交互
The interaction between source and replicas is directional. Property changes and signal emission happen on the source, and are propagated to all replicas. If a property is writable, you can call the setter function on a replica, which is then forwarded to the source. Afterwards, if this call results in a new property value, that value is first changed at the source and then subsequently forwarded to all replicas. To the replica, it is then an asynchronous call, with latency before the change takes effect.
源和副本之间的交互是定向的。属性更改和信号发射发生在源上,并传播到所有副本。如果属性是可写的,则可以在副本上调用setter函数,然后将其转发到源。之后,如果此调用产生新的属性值,则该值首先在源处更改,然后转发给所有副本。对于副本来说,这是一个异步调用,在更改生效之前有延迟。
While technically you can emit a signal on a replica, this is discouraged as it may have unexpected results. It will only trigger slots connected to the replica itself; not slots connected to the source or other replicas. Like property setters, slot invocations on a replica are forwarded to the source to run.
虽然从技术上讲,可以在副本上发出信号,但这是不鼓励的,因为它可能会产生意想不到的结果。它只会触发连接到副本本身的槽;而不是连接到源或其他副本的槽。与属性设置器一样,复制副本上的槽调用被转发到源代码以运行。
Qt Remote Objects automatically implements the behavior described above. There is no need to write any replica implementation code. For dynamic replicas, this is handled automatically at runtime. For repc generated headers, this is handled at compile time.
Qt远程对象自动实现上述行为。不需要编写任何副本实现代码。对于动态副本,这将在运行时自动处理。对于repc生成的头文件,这在编译时处理。