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:
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.
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 https://doc.qt.io/qt-6/qimage.html#Format-enum a {floating point formats}, 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.