Qt GRPC
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.
Overview
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.
Using the Module
Module prerequisites
protoc
, the Protocol Buffers compiler, is required to run the Qt code generator plugins. See Protoc Installation.- Optional: SSL support.
- Optional: gRPC C++ for running the examples.
Note: See the Example of installation for Windows using vcpkg for instructions on installing gRPC and Protobuf, and running Qt GRPC examples.
C++ API
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.
- The qtprotobufgen Tool generates Qt classes from protobuf message definitions. Use the qt_add_protobuf CMake command to automate this process.
- The qtgrpcgen Tool generates interfaces from protobuf service definitions. Use the qt_add_grpc CMake command to automate this process.
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)
QML API
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
Articles and Guides
References
Examples
Licenses and Attributions
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.10.0 may contain third party modules under the following permissive licenses:
Apache License 2.0 |
© 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.