PDA

View Full Version : How to add metatype support for QMap<int,QVariant>?



makinenh
24th February 2010, 14:22
is it possible and how?

My wish is is to use it as Q_PROPERTY. For it I would need QVariant support and metatype is needed for it.

regards, Harri

spud
24th February 2010, 17:15
You need to use the macro Q_DECLARE_METATYPE() (http://doc.trolltech.com/4.6/qmetatype.html#Q_DECLARE_METATYPE) and call qRegisterMetaType() (http://doc.trolltech.com/4.6/qmetatype.html#qRegisterMetaType-2).
You are probably running in to troubles because your types name contains a comma and that doesn't work well with macros. You can fix that with something like:
typedef QMap<int,QVariant> MyType;