Qt GRPC, together with the Qt Protobuf module, enables fast and space-efficient communication with gRPC™ servers. It integrates gRPC services seamlessly into the Qt framework, allowing communication across different programming languages or environments regardless of whether the server is based on Qt.
gRPC is a cross-platform, high-performance Remote Procedure Call (RPC) framework. It uses the Protobuf compiler (protoc) to generate client and server interfaces from
service sections in a protobuf schema for various programming languages. It is commonly used to connect services in microservices-style architectures or to link mobile applications and browsers with
backend systems. For more details, see the gRPC Introduction.
Qt GRPC consists of C++ and Qt Quick APIs that handle the asynchronous nature of Remote Procedure Calls using the well-known Signals & Slots mechanism. It also provides command-line
tools and a CMake API to streamline the generation of Qt-specific interfaces using protoc.
Qt GRPC currently supports client-side functionality. This means it can communicate with a gRPC-compatible server. This could be your own server with its protobuf API or a publicly available API, such as the Google APIs.
protoc, the Protocol Buffers compiler, is required to run the Qt code generator plugins. See Protoc Installation.
Note: See the Example of installation for Windows using vcpkg for instructions on installing gRPC and Protobuf, and running Qt GRPC examples.
To add protobuf files to a Qt-based project and generate the required source code, use the protoc compiler along with the qtgrpcgen and qtprotobufgen Qt plugins.
A minimal example of a CMake project file that uses Qt GRPC can look like this:
cmake_minimum_required(VERSION 3.16...3.22)
project(MyProject)
find_package(Qt6 REQUIRED COMPONENTS Protobuf Grpc)
qt_standard_project_setup()
qt_add_executable(MyApp main.cpp)
qt_add_protobuf(MyApp
PROTO_FILES
path/to/messages.proto
)
qt_add_grpc(MyApp CLIENT
PROTO_FILES
path/to/service.proto
)
target_link_libraries(MyApp PRIVATE Qt6::Protobuf Qt6::Grpc)
The QML types of the module are available through the QtGrpc import. To use the types, add the following import statement to your .qml file:
import QtGrpc
The Qt GRPC module is available under commercial licenses from The Qt Company. In addition, it is available under free software licenses: The GNU General Public License, version 3. See Qt Licensing for further details.
Furthermore, Qt GRPC in Qt 6.8.3 may contain third party modules under the following permissive licenses:
|
Apache License 2.0 |
As part of the free Business evaluation, we offer a free welcome call for companies, to talk about your requirements, and how the Felgo SDK & Services can help you. Just sign up and schedule your call.
Sign up now to start your free Business evaluation: