diff --git a/src/protobuf/qprotobufmessage.cpp b/src/protobuf/qprotobufmessage.cpp index 6afabfb3..2e71726f 100644 --- a/src/protobuf/qprotobufmessage.cpp +++ b/src/protobuf/qprotobufmessage.cpp @@ -99,6 +99,20 @@ bool QProtobufMessage::setProperty(QAnyStringView propertyName, const QVariant & return false; } +/*! + \overload + \since 6.6 +*/ +bool QProtobufMessage::setProperty(QAnyStringView propertyName, QVariant &&value) +{ + Q_D(QProtobufMessage); + + if (auto mp = d->metaProperty(propertyName)) + return mp->writeOnGadget(this, std::move(value)); + + return false; +} + /*! Get the value of the property \a propertyName. @@ -239,6 +253,16 @@ bool QProtobufMessage::setProperty( return mp->writeOnGadget(this, value); } +bool QProtobufMessage::setProperty(const QtProtobufPrivate::QProtobufPropertyOrderingInfo &info, + QVariant &&value) +{ + Q_D(QProtobufMessage); + const auto mp = d->metaProperty(info); + if (!mp) + return false; + return mp->writeOnGadget(this, value); +} + QT_END_NAMESPACE #include "moc_qprotobufmessage.cpp" diff --git a/src/protobuf/qprotobufmessage.h b/src/protobuf/qprotobufmessage.h index 0c767a41..cb231348 100644 --- a/src/protobuf/qprotobufmessage.h +++ b/src/protobuf/qprotobufmessage.h @@ -28,6 +28,7 @@ class QProtobufMessage public: Q_PROTOBUF_EXPORT QVariant property(QAnyStringView propertyName) const; Q_PROTOBUF_EXPORT bool setProperty(QAnyStringView propertyName, const QVariant &value); + Q_PROTOBUF_EXPORT bool setProperty(QAnyStringView propertyName, QVariant &&value); Q_REQUIRED_RESULT Q_PROTOBUF_EXPORT static QProtobufMessagePointer constructByName(const QString &messageType); @@ -50,6 +51,8 @@ protected: QVariant property(const QtProtobufPrivate::QProtobufPropertyOrderingInfo &fieldInfo) const; bool setProperty(const QtProtobufPrivate::QProtobufPropertyOrderingInfo &fieldInfo, const QVariant &value); + bool setProperty(const QtProtobufPrivate::QProtobufPropertyOrderingInfo &fieldInfo, + QVariant &&value); private: const QMetaObject *metaObject() const;