QtProtobuf Namespace

QtProtobuf 命名空间包含支持Qt Protobuf 所需的类型别名和类。更多

头文件: #include <QtProtobuf>
CMake: find_package(Qt6 REQUIRED COMPONENTS Protobuf)
target_link_libraries(mytarget PRIVATE Qt6::Protobuf)
Qt 6.5

(since 6.6) class Any

类型

函数

详细说明

Any

一个辅助类,用于简化与 Any 原型类型的交互。更多

类型文档

enum class QtProtobuf::WireTypes

WireTypes 枚举反映了 protobuf 默认的电线类型。

下表列出了枚举中的值及其对应的类型:

常量说明
QtProtobuf::WireTypes::Unknown-1无效导线类型
QtProtobuf::WireTypes::Varint0int32、int64、uint32、uint64、sint32、sint64、bool、枚举
QtProtobuf::WireTypes::Fixed641fixed64、sfixed64、double
QtProtobuf::WireTypes::LengthDelimited2字符串、字节、嵌入式信息、打包重复字段
QtProtobuf::WireTypes::StartGroup3组。在原语法 3 中已被弃用。Qt Protobuf 不支持。
QtProtobuf::WireTypes::EndGroup4组。在原语法 3 中已弃用。Qt Protobuf 不支持。
QtProtobuf::WireTypes::Fixed325fixed32、sfixed32、float

另请参阅 编码

[alias] QtProtobuf::boolList

bool 列表的别名。

[alias] QtProtobuf::doubleList

double 列表的别名。

[alias] QtProtobuf::fixed32

fixed32 是一个无符号 32 位整数,在 protobuf 中表示为固定大小的 32 位字段,是WireTypes::Fixed32 的别名。

[alias] QtProtobuf::fixed64

fixed64 是一个无符号 64 位整数,在 protobuf 中表示为固定大小的 64 位字段,是WireTypes::Fixed64 的别名。

[alias] QtProtobuf::fixed32List

QtProtobuf::fixed32 列表的别名。

[alias] QtProtobuf::fixed64List

QtProtobuf::fixed64 列表的别名。

[alias] QtProtobuf::floatList

浮子列表的别名。

[alias] QtProtobuf::int32

int32 是一个普通的有符号 32 位整数,在 protobuf 中表示为大小可变的整数,是WireTypes::Varint 的别名。

[alias] QtProtobuf::int64

int64 是一个普通的带符号 64 位整数,在 protobuf 中表示为大小可变的整数,是WireTypes::Varint 的别名。

[alias] QtProtobuf::int32List

QtProtobuf::int32 列表的别名。

[alias] QtProtobuf::int64List

QtProtobuf::int64 列表的别名。

[alias] QtProtobuf::sfixed32

sfixed32 是带符号的 32 位整数,在 protobuf 中表示为固定大小的 32 位字段,是WireTypes::Fixed32 的别名。

[alias] QtProtobuf::sfixed64

sfixed64 是带符号的 64 位整数,在 protobuf 中表示为固定大小的 64 位字段,是WireTypes::Fixed64 的别名。

[alias] QtProtobuf::sfixed32List

QtProtobuf::sfixed32 列表的别名。

[alias] QtProtobuf::sfixed64List

QtProtobuf::sfixed64 列表的别名。

[alias] QtProtobuf::sint32

sint32 是带有强制符号标记的 32 位整数,在 protobuf 中表示为可变大小整数,是WireTypes::Varint 的别名。sint32 使用 ZigZag 转换进行序列化,以减小负数的大小。

另请参阅 带符号整数

[alias] QtProtobuf::sint64

sint64 是带有强制符号标记的 64 位整数,在 protobuf 中表示为可变大小整数,是WireTypes::Varint 的别名。sint64 使用 ZigZag 转换进行序列化,以减小负数的大小。

另请参阅 带符号整数

[alias] QtProtobuf::sint32List

QtProtobuf::sint32 列表的别名。

[alias] QtProtobuf::sint64List

QtProtobuf::sint64 列表的别名。

[alias] QtProtobuf::uint32

uint32 是无符号 32 位整数,在 protobuf 中表示为大小可变的整数,是WireTypes::Varint 的别名。

[alias] QtProtobuf::uint64

uint64 是一个无符号 64 位整数,在 protobuf 中表示为大小可变的整数,是WireTypes::Varint 的别名。

[alias] QtProtobuf::uint32List

QtProtobuf::uint32 列表的别名。

[alias] QtProtobuf::uint64List

QtProtobuf::uint64 列表的别名。

功能文档

template <typename T, std::enable_if_t<std::is_enum<T>::value, bool> = true> void qRegisterProtobufEnumType()

QtProtobuf 全局序列化器注册表中为枚举类型T 注册序列化器。

该函数通常由生成的代码调用。

template <typename K, typename V, QtProtobuf::if_protobuf_map<K, V> = true> void qRegisterProtobufMapType()

注册 Protobuf 映射类型KVV 必须是QProtobufMessage 。该函数通常由生成的代码调用。

template <typename T, QtProtobuf::if_protobuf_message<T> = true> void qRegisterProtobufType()

注册 Protobuf 类型T。该函数通常由生成的代码调用。

void qRegisterProtobufTypes()

调用该函数可在序列化器注册表中注册当前已知的所有 protobuf 类型。

注意: 自 Qt 6.6.3 版本起,您无需手动调用此函数,因为它会被自动调用。对于早期版本,最好在尝试序列化/反序列化之前调用该函数。

void QtProtobuf::registerProtobufQtCoreTypes()

为 Qt::ProtobufQtCoreTypes 库注册序列化程序。

void QtProtobuf::registerProtobufQtGuiTypes()

为 Qt::ProtobufQtGuiTypes 库注册序列化程序。

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