QVariantValue - "QT_DEPRECATED" - what is the replacement?
I need to convert legacy Qt code from 4 to 5.1 now I have compile error in visual studio 2010:
SingleItem* item = qVariantValue<SingleItem*>(index.data());
gives me:
.cpp (63): error C2065: 'qVariantValue': undeclared identifier
when i go to the header i see:
#if QT_DEPRECATED_SINCE(5, 0)
template<typename T>
inline QT_DEPRECATED T qVariantValue(const QVariant &variant)
{ return qvariant_cast<T>(variant); }
template<typename T>
inline QT_DEPRECATED bool qVariantCanConvert(const QVariant &variant)
{ return variant.template canConvert<T>(); }
#endif
ok ... so what's the replacement?
+3
source to share
1 answer
See compatibility notes .
For qVariantValue
use QVariant::value<T>
.
index.data().value<SingleItem*>();
+7
source to share