QRemoteObjectRegistryHost Class
Qt Remote Objects 网络中的 A(主机/注册表)节点。更多内容...
| 标题: | #include <QRemoteObjectRegistryHost> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS RemoteObjects) target_link_libraries(mytarget PRIVATE Qt6::RemoteObjects) |
| qmake: | QT += remoteobjects |
| 继承自: | QRemoteObjectHostBase |
公共函数
| QRemoteObjectRegistryHost(const QUrl ®istryAddress = QUrl(), QObject *parent = nullptr) |
重新实现的公共函数
| virtual bool | setRegistryUrl(const QUrl ®istryUrl) override |
详细说明
QRemoteObjectRegistryHost 类为QtRemoteObjects 网络提供了一个入口点。一个网络可以简单到仅包含两个节点,也可以是任意复杂的进程和设备集合。
一个 QRemoteObjectRegistryHost 具有与QRemoteObjectHost 相同的功能(包括QRemoteObjectNode 支持的所有功能),此外还是该注册表的所有者。任何连接到此节点的QRemoteObjectHost 节点,其所有源对象都将由该注册表提供。
节点仅支持连接到一个registry ;当已设置注册表时调用QRemoteObjectNode::setRegistryUrl 将被视为错误。对于安全网络和非安全网络(此类场景下可能需要使用不同的注册表)的情况,建议创建独立的节点分别连接,从而实质上构建两个独立的Qt Remote Objects 网络。
节点可以使用connectToNode 直接相互连接,也可以使用QRemoteObjectRegistry 来简化连接。
QRemoteObjectRegistry 是一个特殊的副本,每个连接到注册表 URL 的节点均可使用。它知道如何连接到网络上的每个 QRemoteObjectSource 对象。
另请参阅 QRemoteObjectNode 和QRemoteObjectHost 。
成员函数文档
QRemoteObjectRegistryHost::QRemoteObjectRegistryHost(const QUrl ®istryAddress = QUrl(), QObject *parent = nullptr)
使用给定的parent 创建一个新的QRemoteObjectRegistryHost节点。RegistryHost节点的功能与QRemoteObjectHost 节点相同,不同之处在于:它无法连接到QRemoteObjectRegistry ,而是将提供的HostQUrl (registryAddress )作为注册表的地址,供其他节点连接。
[override virtual] bool QRemoteObjectRegistryHost::setRegistryUrl(const QUrl ®istryUrl)
重新实现了属性QRemoteObjectNode::registryUrl 的访问函数。
如果构造函数中未设置QUrl ,则可使用此方法将该节点的地址设置为registryUrl (供其他节点连接到该节点)。由于该节点将成为注册表,调用此设置方法将导致该节点使用该 URL 作为主机地址。 所有其他 Node 均使用QRemoteObjectNode::setRegistryUrl 方法向 Registry 发起连接。
如果注册表地址已设置,则返回true ;否则返回false 。
另请参阅 QRemoteObjectRegistryHost() 和QRemoteObjectNode::setRegistryUrl 。
© 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.