Protobuf Qt Core Types Module

Provides support for using native Qt Core types in protobuf. More...

This module is in Technical Preview state.

This module was introduced in Qt 6.6.

Detailed Description

Qt::ProtobufQtCoreTypes is a library with pre-defined protobuf messages designed to encapsulate a selection of Qt Core types.

List of supported Qt Core types:

Qt Core usage

To enable Qt Core types support, add ProtobufQtCoreTypes as a dependency to your CMake project:

...
find_package(Qt REQUIRED COMPONENTS Protobuf ProtobufQtCoreTypes)
... # After target creation
target_link_libraries(${TARGET} PRIVATE Qt::ProtobufQtCoreTypes)

Before any serialization or deserialization of messages that use Qt Core types as fields, call the registration method:

// e.g. in main.cpp
QtProtobuf::qRegisterProtobufQtCoreTypes();
...

All supported messages are described in a special .proto file, QtCore.proto, that describes Qt types from the Qt Core module.

You can also use the file to generate code for other languages or frameworks.

Import the required Qt Core types module in your interface .proto file. For example:

syntax = "proto3";

package project.module.component;

import "QtCore/QtCore.proto";

message QUrlMessage {
    QtCore.QUrl url = 1;
}

The Qt Protobuf generator detects Qt Core types, supplied by the ProtobufQtCoreTypes package, and uses them directly. This gives you the flexibility to use these types without additional conversion.

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