QRemoteObjectRegistryHost Class

Qt Remote Objects 网络上的(主机/注册表)节点。更多

头文件: #include <QRemoteObjectRegistryHost>
CMake: find_package(Qt6 REQUIRED COMPONENTS RemoteObjects)
target_link_libraries(mytarget PRIVATE Qt6::RemoteObjects)
qmake: QT += remoteobjects
继承: QRemoteObjectHostBase

公共函数

QRemoteObjectRegistryHost(const QUrl &registryAddress = QUrl(), QObject *parent = nullptr)

重新实现的公共函数

virtual bool setRegistryUrl(const QUrl &registryUrl) override

详细说明

QRemoteObjectRegistryHost 类为QtRemoteObjects 网络提供了一个入口点。网络可以是简单的两个节点,也可以是任意复杂的进程和设备。

QRemoteObjectRegistryHost 具有与QRemoteObjectHost 相同的功能(包括QRemoteObjectNode 支持的所有功能),此外还是注册表的所有者。任何连接到该节点的QRemoteObjectHost 节点,其所有源对象都将由注册表提供。

节点只支持连接到一个注册表,在注册表已设置的情况下调用QRemoteObjectNode::setRegistryUrl 会被视为错误。对于安全和不安全网络(适用于不同的注册表),建议分别创建不同的节点来连接,这样实际上就创建了两个独立的Qt Remote Objects 网络。

节点可以直接使用connectToNode 互相连接,也可以使用QRemoteObjectRegistry 简化连接。

QRemoteObjectRegistry 是一个特殊的副本,可供每个连接到注册 Url 的节点使用。它知道如何连接到网络上的每个 QRemoteObjectSource 对象。

另请参阅 QRemoteObjectNodeQRemoteObjectHost

成员函数文档

QRemoteObjectRegistryHost::QRemoteObjectRegistryHost(const QUrl &registryAddress = QUrl(), QObject *parent = nullptr)

用给定的parent 构建一个新的 QRemoteObjectRegistryHost 节点。RegistryHost 节点具有与QRemoteObjectHost 节点相同的功能,但所提供的 HostQUrl (registryAddress) 并不能连接到QRemoteObjectRegistry ,而是成为供其他节点连接的注册表地址。

[override virtual] bool QRemoteObjectRegistryHost::setRegistryUrl(const QUrl &registryUrl)

重构属性QRemoteObjectNode::registryUrl 的访问函数。

如果在构造函数中未设置QUrl ,则可使用此方法将此节点的地址设置为registryUrl (用于其他节点连接到此节点)。由于此节点成为注册中心,调用此设置方法会使此节点使用 url 作为主机地址。所有其他节点都使用QRemoteObjectNode::setRegistryUrl 方法启动与注册表的连接。

如果注册表地址已设置,则返回true ,否则返回false

另请参阅 QRemoteObjectRegistryHost() 和QRemoteObjectNode::setRegistryUrl

© 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.