Protobuf Qt GUI Types Module | Qt Protobuf | Qt 6.10.3
Description: Provides support for using native Qt Gui types in protobuf.

- Qt 6.10
- Qt Protobuf
- Protobuf Qt GUI Types Module
- Qt 6.10.3 Reference Documentation

# Protobuf Qt GUI Types Module

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

This module was introduced in Qt 6.6.

## Detailed Description

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

List of supported Qt Gui types:

- QImage
- QMatrix4x4
- QQuaternion
- QRgba64
- QColor
- QTransform
- QVector2D
- QVector3D
- QVector4D

### Qt GUI usage

To enable Qt GUI types support, add ProtobufQtGuiTypes as a dependency to your CMake project:

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

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

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

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

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

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

     syntax = "proto3";

     package project.module.component;

     import "QtGui/QtGui.proto";

     message QMatrix4x4Message {
         QtGui.QMatrix4x4 matrix = 1;
     }

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

In CMake, you can extract the proto include path from the library using the `QT_PROTO_INCLUDES` target property:

     qt_add_protobuf(MyProtoLib
         PROTO_FILES
             MyQtGuiTypesUsage.proto
         PROTO_INCLUDES
             $<TARGET_PROPERTY:Qt::ProtobufQtGuiTypes,QT_PROTO_INCLUDES>
     )

#### QImage serialization

The ProtobufQtGuiTypes library provides the possibility to work with the QImage class. Usually, the library converts all QImage objects in to `PNG` format. But if the QImage was created using one of the floating point formats of QImage::Format, then conversion to `PNG` will lead to data loss. To prevent data loss, the library automatically converts the image file to `TIFF` format, if it is supported by the system, otherwise converts to `PNG`.

Note: if you don't want to use `TIFF`, you need to convert the image explicitly into a non-floating point format.