I have a list of QObjects* and want to add them to my DataModel. But the datamodel needs a QVariant instead of QObject.
Is is possible to convert QObjects to QVariant?
I have a list of QObjects* and want to add them to my DataModel. But the datamodel needs a QVariant instead of QObject.
Is is possible to convert QObjects to QVariant?
Yes, because it is not a type supported by QVariant::Type
it falls back to QMetaType::Type
support. You must use QVariant::setValue(..)
or QVariant::fromValue(..)
to set it as the QVariant
constructors don't have an overload for QObject*
.