远程对象交互
源和副本之间的交互是单向的。属性更改和信号发射发生在源上,并传播到所有副本。如果某个属性可写,则可以在副本上调用设置器函数,该调用随后会被转发到源。 随后,如果该调用导致属性值发生变化,该值将首先在源实例上更新,然后转发给所有副本。对于副本而言,这属于异步调用,变更生效前会存在延迟。
虽然从技术上讲,您可以在副本上发出信号,但不建议这样做,因为这可能会导致意想不到的结果。它只会触发连接到该副本本身的槽,而不会触发连接到源或其它副本的槽。与属性设置器类似,在副本上调用的槽也会被转发到源处执行。
Qt Remote Objects 会自动实现上述行为。无需编写任何副本实现代码。对于动态副本,这会在运行时自动处理;对于repc生成的头文件,则在编译时处理。
© 2026 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.