本页内容

QGrpcClientBase Class

QGrpcClientBase 类是生成的客户端接口的基础类。更多内容...

头文件: #include <QGrpcClientBase>
CMake: find_package(Qt6 REQUIRED COMPONENTS Grpc)
target_link_libraries(mytarget PRIVATE Qt6::Grpc)
自: Qt 6.5
继承自: QObject

属性

  • (since 6.7) channel : std::shared_ptr<QAbstractGrpcChannel>

公共函数

virtual ~QGrpcClientBase() override
bool attachChannel(std::shared_ptr<QAbstractGrpcChannel> channel)
(since 6.7) std::shared_ptr<QAbstractGrpcChannel> channel() const

信号

(since 6.7) void channelChanged()

详细说明

QGrpcClientBase 类为生成的客户端接口提供了一组通用功能 gRPC™ 服务定义生成的客户端接口提供了一套通用功能。

不应直接调用该类的 RPC 方法。

注意: 非 const 成员函数强制执行线程 安全性。这些函数必须从创建该对象的同一thread 中调用。

属性文档

[since 6.7] channel : std::shared_ptr<QAbstractGrpcChannel>

该属性存储了与该客户端关联的通道。该通道用作 gRPC 操作的传输层。

该枚举类型在 Qt 6.7 中引入。

访问函数:

std::shared_ptr<QAbstractGrpcChannel> channel() const
bool attachChannel(std::shared_ptr<QAbstractGrpcChannel> channel)

通知信号:

另请参阅 attachChannel()。

成员函数文档

[override virtual noexcept] QGrpcClientBase::~QGrpcClientBase()

销毁QGrpcClientBase 。

bool QGrpcClientBase::attachChannel(std::shared_ptr<QAbstractGrpcChannel> channel)

将channel 连接到客户端,作为gRPC 操作的传输层。如果通道连接成功,则返回true ;否则,返回false 。

请求和响应消息将按通道支持的格式进行序列化。

注意: 警告:Qt GRPC 无法保证通道层面的线程安全。您必须在与QGrpcClientBase 相同的线程上调用与通道相关的函数。

注意: 属性channel 的设置 函数。

[since 6.7] std::shared_ptr<QAbstractGrpcChannel> QGrpcClientBase::channel() const

返回与该客户端关联的通道。

注意: 这是 channel 属性的获取 函数。

该函数于 Qt 6.7 版本中引入。

[signal, since 6.7] void QGrpcClientBase::channelChanged()

表示有一个新通道已连接到客户端。

注意: 这是属性channel的通知 信号。

该函数在 Qt 6.7 中引入。

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