QProtobufMessage Class

Base class for all protobuf messages. More...

Header: #include <QProtobufMessage>
CMake: find_package(Qt6 REQUIRED COMPONENTS Protobuf)
target_link_libraries(mytarget PRIVATE Qt6::Protobuf)
Since: Qt 6.5
Inherited By:

QtProtobuf::Any

Status: Technical Preview

Public Functions

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

Static Public Members

QProtobufMessagePointer constructByName(const QString &messageType)

Detailed Description

Provides access to the properties of a message, using setProperty() and property(), without depending on what the message is.

Member Function Documentation

[static] QProtobufMessagePointer QProtobufMessage::constructByName(const QString &messageType)

Constructs QProtobufMessage using messageType. Returns a pointer to the constructed QProtobufMessage.

This function attempts to create a message whose type matches messageType. If messageType is unknown, the function returns nullptr. If the message is not found in the registry, the function returns nullptr. Ownership of the constructed message is given to the function caller.

QVariant QProtobufMessage::property(QAnyStringView propertyName) const

Get the value of the property propertyName.

If the propertyName isn't known then the returned QVariant is invalid.

See also setProperty().

bool QProtobufMessage::setProperty(QAnyStringView propertyName, const QVariant &value)

Set the property propertyName to the value stored in value.

If the propertyName isn't a part of the known fields then the value will not be written and the function returns false.

Returns false if it failed to store the value on the property. Otherwise true.

See also property().

[since 6.6] bool QProtobufMessage::setProperty(QAnyStringView propertyName, QVariant &&value)

This is an overloaded function.

This function was introduced in Qt 6.6.

[since 6.7] QList<QByteArray> QProtobufMessage::unknownFieldData(qint32 field) const

Returns the unknown field values sorted as they were received from the wire.

This function was introduced in Qt 6.7.

[since 6.7] QList<qint32> QProtobufMessage::unknownFieldNumbers() const

Returns the field numbers that were not known to QtProtobuf during deserialization.

This function was introduced in Qt 6.7.

Related Non-Members

[alias] QProtobufMessagePointer

Synonym for std::unique_ptr<QProtobufMessage, QProtobufMessageDeleter>. Use this to manage the lifetime of dynamically allocated QProtobufMessages, such as those created by calling QProtobufMessage::constructByName.

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