
Originally Posted by
Dusdan
you can store whatever you want, in fact QColor isn't supported natively (there's no toColor() method), because it's not part of QtCore.
you can use it this way:
MyType t;
QVariant var = t;
...
MyType t2 = var.value<MyType>();
You can do this only for Registered types otherwise you obtain a compiler error
You can register a custom type in this way
Q_DECLARE_METATYPE(MyType);
Q_DECLARE_METATYPE(MyType);
To copy to clipboard, switch view to plain text mode
If you want to register also a type name you can use
int myTypeId = qRegisterMetaType<MyType>("MyType")
int myTypeId = qRegisterMetaType<MyType>("MyType")
To copy to clipboard, switch view to plain text mode
Bookmarks