本页内容

QProtobufJsonSerializer Class

QProtobufJsonSerializer 类是一个接口,用于实现将QProtobufMessage 对象序列化为 JSON 及反序列化为 对象的基本功能。更多内容...

头文件: #include <QProtobufJsonSerializer>
CMake: find_package(Qt6 REQUIRED COMPONENTS Protobuf)
target_link_libraries(mytarget PRIVATE Qt6::Protobuf)
自: Qt 6.7
继承自: QAbstractProtobufSerializer

重新实现的公共函数

virtual QAbstractProtobufSerializer::Error lastError() const override
virtual QString lastErrorString() const override

详细描述

QProtobufJsonSerializer 类为实现 protobuf 消息并继承自QProtobufMessage 的类注册序列化器/反序列化器。这些类是基于.proto 文件,通过 CMake 函数qt_add_protobuf或直接运行qtprotobufgen自动生成的。

成员函数文档

[override virtual] QAbstractProtobufSerializer::Error QProtobufJsonSerializer::lastError() const

重写了:QAbstractProtobufSerializer::lastError() const。

返回该序列化器实例的最后一次反序列化错误。

另请参阅 lastErrorString()。

[override virtual] QString QProtobufJsonSerializer::lastErrorString() const

重写了:QAbstractProtobufSerializer::lastErrorString() const。

返回该序列化器实例的最后一个反序列化错误字符串。

另请参阅 lastError()。

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