diff options
Diffstat (limited to 'src/qml/qml/qqmlvaluetypewrapper_p.h')
-rw-r--r-- | src/qml/qml/qqmlvaluetypewrapper_p.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlvaluetypewrapper_p.h b/src/qml/qml/qqmlvaluetypewrapper_p.h index df173e6325..5b3894a07f 100644 --- a/src/qml/qml/qqmlvaluetypewrapper_p.h +++ b/src/qml/qml/qqmlvaluetypewrapper_p.h @@ -120,6 +120,17 @@ public: ExecutionEngine *engine, const void *, const QMetaObject *metaObject, QMetaType type); QVariant toVariant() const; + + template<typename ValueType> + ValueType *cast() + { + if (QMetaType::fromType<ValueType>() != d()->metaType()) + return nullptr; + if (d()->isReference() && !readReferenceValue()) + return nullptr; + return static_cast<ValueType *>(d()->gadgetPtr()); + } + bool toGadget(void *data) const; bool isEqual(const QVariant& value) const; int typeId() const; |