Unsolved How to append different struct types to a QList?
-
I have different structures I want to append them to a QList can this be done using QVarient?Please suggest
-
register your custom types using Q_DECLARE_METATYPE
struct MyStruct1 { ... }; Q_DECLARE_METATYPE(MyStruct1) struct MyStruct2 { ... }; Q_DECLARE_METATYPE(MyStruct2)
QVariantList list; list << QVariant::fromValue<MyStruct1>( MyStruct1() ); list << QVariant::fromValue<MyStruct2>( MyStruct2() )