远程对象交互

源和副本之间的交互是定向的。属性更改和信号发射发生在源上,并传播到所有副本。如果属性是可写的,可以在副本上调用 setter 函数,然后将其转发给源。之后,如果该调用产生了新的属性值,该值会首先在源上更改,然后转发到所有副本。对于副本来说,这是一个异步调用,在更改生效之前会有延迟。

虽然从技术上讲,您可以在副本上发出信号,但我们不鼓励这样做,因为这样做可能会产生意想不到的结果。它只会触发连接到副本本身的槽,而不会触发连接到源或其他副本的槽。与属性设置器一样,副本上的槽调用也会转发给源运行。

Qt Remote Objects 在这种情况下,"replica "会自动执行上述行为。无需编写任何副本执行代码。对于动态副本,这将在运行时自动处理。对于repc生成的头文件,则在编译时处理。

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.