QRemoteObjectHost Class

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

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

属性

公共函数

QRemoteObjectHost(QObject *parent = nullptr)
QRemoteObjectHost(const QUrl &address, QObject *parent)
QRemoteObjectHost(const QUrl &address, const QUrl &registryAddress = QUrl(), QRemoteObjectHostBase::AllowedSchemas allowedSchemas = BuiltInSchemasOnly, QObject *parent = nullptr)

重新实现的公共函数

virtual QUrl hostUrl() const override
virtual bool setHostUrl(const QUrl &hostAddress, QRemoteObjectHostBase::AllowedSchemas allowedSchemas = BuiltInSchemasOnly) override

信号

静态公共成员

(since 6.7) void setLocalServerOptions(QLocalServer::SocketOptions options)

详细说明

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

QRemoteObjectHost 具有与 QRemoteObjectNodes 相同的功能,但它们也可以连接到网络上的源对象并共享源对象。

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

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

另请参阅 QRemoteObjectNodeQRemoteObjectRegistryHost

属性文档

hostUrl : QUrl

该属性包含节点的主机地址。

这是该节点远程传输的源对象所在的地址。

访问功能:

virtual QUrl hostUrl() const override
virtual bool setHostUrl(const QUrl &hostAddress, QRemoteObjectHostBase::AllowedSchemas allowedSchemas = BuiltInSchemasOnly) override

Notifier 信号:

void hostUrlChanged()

成员函数 文档

QRemoteObjectHost::QRemoteObjectHost(QObject *parent = nullptr)

用给定的parent 构造一个新的 QRemoteObjectHost Node(即支持在 QtRO 网络上公开对象的 Node)。该构造函数专门用于支持未来的 QML,因为在调用setHostUrl 之前,它将无法连接。

另请参阅 setHostUrl() 和setRegistryUrl()。

QRemoteObjectHost::QRemoteObjectHost(const QUrl &address, QObject *parent)

构建一个新的 QRemoteObjectHost Node(即支持在 QtRO 网络上公开对象的 Node),url 为address ,给定parent 。提供此重载是为了方便在不提供注册表地址的情况下指定QObject 父节点。

另请参阅 setHostUrl() 和setRegistryUrl()。

QRemoteObjectHost::QRemoteObjectHost(const QUrl &address, const QUrl &registryAddress = QUrl(), QRemoteObjectHostBase::AllowedSchemas allowedSchemas = BuiltInSchemasOnly, QObject *parent = nullptr)

构建一个新的 QRemoteObjectHost 节点(即支持在 QtRO 网络上公开对象的节点),地址为address 。如果设置了该参数,registryAddress 将用于连接到所提供地址的QRemoteObjectRegistry 。只有在注册表将 url 的模式用作外部模式时,才需要allowedSchemas 参数(应将其设置为AllowExternalRegistration )。

另请参阅 setHostUrl() 和setRegistryUrl()。

[override virtual] QUrl QRemoteObjectHost::hostUrl() const

QUrl 的形式返回QRemoteObjectNode 的主机地址。如果节点不是主机节点,则返回空的QUrl

注: 属性 hostUrl 的获取函数。

另请参阅 setHostUrl() 。

[override virtual] bool QRemoteObjectHost::setHostUrl(const QUrl &hostAddress, QRemoteObjectHostBase::AllowedSchemas allowedSchemas = BuiltInSchemasOnly)

为主机设置hostAddress QRemoteObjectNode

如果主机地址已设置,则返回true ,否则返回false

只有在注册表将 url 的模式用作外部模式时,才需要allowedSchemas 参数(应设置为AllowExternalRegistration )。

注: 属性hostUrl 的设置函数。

另请参阅 hostUrl() 。

[static, since 6.7] void QRemoteObjectHost::setLocalServerOptions(QLocalServer::SocketOptions options)

QLocalServer 后端套接字选项设置为options

必须在QRemoteObjectHost 对象开始监听前设置。它对已经监听的QRemoteObjectHost 对象或使用与QLocalServer 不同后端的QRemoteObjectHost 对象没有影响。如果地址参数为非空,QRemoteObjectHost 对象会在构建过程中开始监听,否则会在通过setHostUrl() 设置地址时开始监听。

该函数在 Qt 6.7 中引入。

另请参阅 setHostUrl() 和QRemoteObjectHost()。

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