[Interest] Convert QVariant of QQmlListProperty<T> to QVariantList

Brian Dentino brian.dentino at gmail.com
Mon Oct 13 19:21:14 CEST 2014


Hi,

I'm trying to do some introspection of generic QObject-derived classes where I essentially iterate over all the properties and serialize their values into a hashmap or json-like tree structure. I'm using the QMetaObject class to get the names of all properties and their values as QVariants, then checking canConvert() in a switch statement to identify the type and serialize accordingly. This works for pretty much any primitive type, most basic container types and works recursively for QObject-based types as well. However, when I'm stuck when it comes to handling a property type of QQmlListProperty<T> (where T is not necessarily known, but it can be assumed to be derived from QObject). 

Is there a way to convert a QVariant that contains a QQmlListProperty<T> into a QVariantList? .canConvert<QVariantList>() does not seem to work in this case.

Brian


More information about the Interest mailing list