diff options
| author | Olivier Goffart <ogoffart@woboq.com> | 2014-08-03 13:37:01 +0200 |
|---|---|---|
| committer | Olivier Goffart <ogoffart@woboq.com> | 2014-10-30 13:29:10 +0100 |
| commit | d9e8571f4de47d3587de07aaff71eadff771f1e2 (patch) | |
| tree | d79c9b0b23d0f0092f94331a17d7cea46fb6f097 /src/corelib/kernel/qmetaobject.cpp | |
| parent | ae981f224de9d2a24bfb1547e2049b6ccd9fc4ac (diff) | |
Be able to read and write properties to Q_GADGET
Change-Id: Ic12f465d31459748ca08ac8c457fd61a5773e2e2
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/corelib/kernel/qmetaobject.cpp')
| -rw-r--r-- | src/corelib/kernel/qmetaobject.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index f351f228fd6..7f37a1ce9a0 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -2969,6 +2969,49 @@ bool QMetaProperty::reset(QObject *object) const QMetaObject::metacall(object, QMetaObject::ResetProperty, idx + mobj->propertyOffset(), argv); return true; } +/*! + \since 5.5 + + Reads the property's value from the given \a gadget. Returns the value + if it was able to read it; otherwise returns an invalid variant. + + This function should only be used if this is a property of a Q_GADGET +*/ +QVariant QMetaProperty::readOnGadget(const void *gadget) const +{ + Q_ASSERT(priv(mobj->d.data)->flags & PropertyAccessInStaticMetaCall && mobj->d.static_metacall); + return read(reinterpret_cast<const QObject*>(gadget)); +} + +/*! + \since 5.5 + + Writes \a value as the property's value to the given \a gadget. Returns + true if the write succeeded; otherwise returns \c false. + + This function should only be used if this is a property of a Q_GADGET +*/ +bool QMetaProperty::writeOnGadget(void *gadget, const QVariant &value) const +{ + Q_ASSERT(priv(mobj->d.data)->flags & PropertyAccessInStaticMetaCall && mobj->d.static_metacall); + return write(reinterpret_cast<QObject*>(gadget), value); +} + +/*! + \since 5.5 + + Resets the property for the given \a gadget with a reset method. + Returns \c true if the reset worked; otherwise returns \c false. + + Reset methods are optional; only a few properties support them. + + This function should only be used if this is a property of a Q_GADGET +*/ +bool QMetaProperty::resetOnGadget(void *gadget) const +{ + Q_ASSERT(priv(mobj->d.data)->flags & PropertyAccessInStaticMetaCall && mobj->d.static_metacall); + return reset(reinterpret_cast<QObject*>(gadget)); +} /*! Returns \c true if this property can be reset to a default value; otherwise |
