Quantcast
Channel: QtWebEngine
Viewing all articles
Browse latest Browse all 13965

QVariant: How to extract value into a pointer?

$
0
0
One can use QVariant::QVariant(int typeId, const void * copy) to create a QVariant of specific type with specific value, without knowing the actual definition of the type. I could not figure out how to do the opposite operation: extract a value to a pointer without knowing the actual definition of the type. I would expect something like bool QVariant::value(void *destination, int typeid) to exist, which would make a copy of the internal value to an object at pointer destination, assuming that destination points to an object of type typeid, but without knowing the actual definition of that object. I could only find a template method T value() which requires to know T. What would be a way to extract QVariant’s value to a memory location of an object based on its type, but without knowing the object definition?

Viewing all articles
Browse latest Browse all 13965

Trending Articles