QGrpcClientBase Class | Qt GRPC | Qt 6.12.0
Description: The QGrpcClientBase class serves as base for generated client interfaces.
Keywords: class

- Qt 6.12
- Qt GRPC
- C++ Classes
- QGrpcClientBase
- Qt 6.12.0 Reference Documentation

# QGrpcClientBase Class

The QGrpcClientBase class serves as base for generated client interfaces. More...

Header: | `#include <QGrpcClientBase>`
CMake: | `find_package(Qt6 REQUIRED COMPONENTS Grpc)` `target_link_libraries(mytarget PRIVATE Qt6::Grpc)`
Since: | Qt 6.5
Inherits: | QObject

- List of all members, including inherited members

## Properties

- `(since 6.7)` channel : std::shared_ptr<QAbstractGrpcChannel>

## Public Functions

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

## Signals

`(since 6.7)` void | channelChanged()

## Detailed Description

The QGrpcClientBase class provides a common set of functionalities for the generated client interface of the gRPC™ service definition.

The RPC methods of this class should not be called directly.

Note: Thread safety is enforced for the non-const member functions. These functions must be called from the same thread in which the object was created.

## Property Documentation

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

This property holds the channel attached to this client. The channel is used as the transport layer for gRPC operations.

This enumeration was introduced in Qt 6.7.

Access functions:

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

Notifier signal:

void | channelChanged()

See also attachChannel().

## Member Function Documentation

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

Destroys the QGrpcClientBase.

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

Attaches channel to the client as transport layer for gRPC operations. Returns `true` if the channel successfully attached; otherwise, returns `false`.

Request and response messages will be serialized in a format that the channel supports.

Note: Warning: Qt GRPC doesn't guarantee thread safety on the channel level. You have to invoke the channel-related functions on the same thread as QGrpcClientBase.

Note: Setter function for property channel.

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

Returns the channel attached to this client.

Note: Getter function for property channel.

This function was introduced in Qt 6.7.

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

Indicates that a new channel got attached to the client.

Note: Notifier signal for property channel.

This function was introduced in Qt 6.7.