QProtobufMessage Class

Base class for all protobuf messages. 更多...

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

公共函數

QVariant property (QAnyStringView propertyName ) const
bool setProperty (QAnyStringView propertyName , const QVariant & value )

靜態公共成員

QProtobufMessagePointer constructByName (const QString & messageType )
QProtobufMessagePointer

詳細描述

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

成員函數文檔編製

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

Constructs QProtobufMessage 使用 messageType . Returns a pointer to the constructed QProtobufMessage .

This function attempts to create a message whose type matches messageType 。若 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 .

propertyName isn't known then the returned QVariant 無效。

另請參閱 setProperty ().

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

Set the property propertyName to the value stored in value .

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

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

另請參閱 property ().

相關非成員

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