QProtobufMessage类
所有protobuf消息的基类。 更多信息...
| 头文件 | #include <QProtobufMessage> | 
| CMake | find_package(Qt6 REQUIRED COMPONENTS Protobuf) target_link_libraries(mytarget PRIVATE Qt6::Protobuf) | 
| 自从 | Qt 6.5 | 
| 继承自 | |
| 状态 | 技术预览 | 
公共函数
| QVariant | property(QAnyStringView propertyName) const | 
| bool | setProperty(QAnyStringView propertyName, const QVariant &value) | 
| (since 6.6)bool | setProperty(QAnyStringView propertyName, QVariant &&value) | 
| (since 6.7)QList<QByteArray> | unknownFieldData(qint32 field) const | 
| (since 6.7)QList<qint32> | unknownFieldNumbers() const | 
静态公共成员
| QProtobufMessagePointer | constructByName(const QString &messageType) | 
相关非成员
成员函数文档
[static] QProtobufMessagePointer QProtobufMessage::constructByName(const QString &messageType)
使用messageType构造QProtobufMessage。返回指向构造的QProtobufMessage的指针。
此函数尝试创建一个与messageType匹配的消息类型。如果messageType未知,则该函数返回nullptr。如果消息类型在注册表中未找到,则该函数返回nullptr。所构造消息的所有权归函数调用者所有。
QVariant QProtobufMessage::property(QAnyStringView propertyName) const
获取属性propertyName的值。
如果propertyName未知,则返回的QVariant是无效的。
另请参阅 setProperty()。
bool QProtobufMessage::setProperty(QAnyStringView propertyName, const QVariant &value)
将属性 propertyName 设置为存储在 value 中的值。
如果 propertyName 不是已知字段的一部分,则不会写入该值,并且函数返回 false。
如果无法在属性上存储 value,则返回 false。否则返回 true。
另请参阅 property()。
[since 6.6] bool QProtobufMessage::setProperty(QAnyStringView propertyName, QVariant &&value)
这是一个重载函数。
此函数是在 Qt 6.6 中引入的。
[since 6.7] QList<QByteArray> QProtobufMessage::unknownFieldData(qint32 field) const
返回按从线接收的顺序排序的未知 field 值。
此函数是在 Qt 6.7 中引入的。
[since 6.7] QList<qint32> QProtobufMessage::unknownFieldNumbers() const
返回在反序列化期间 QtProtobuf 未知的目标字段编号。
此函数是在 Qt 6.7 中引入的。
相关非成员
[alias] QProtobufMessagePointer
std::unique_ptr<QProtobufMessage, QProtobufMessageDeleter> 的同义词。使用此来管理动态分配的 QProtobufMessage 的生存期,如下所示:通过调用 QProtobufMessage::constructByName 创建的 QProtobufMessage。
© 2024 Qt 公司有限公司。此处包含的文档贡献的版权属于其各自的所有者。所提供的文档是根据自由软件开发基金会发布的 GNU 自由文档许可协议版本 1.3 的条款许可的。Qt 和相应的标志是芬兰和/或全世界其他国家的 The Qt Company Ltd. 的商标。所有其他商标均为其各自所有者的财产。