PDA

View Full Version : How to use QVariant with enum?



FinderCheng
25th December 2010, 17:45
I want to use an enum as the user data in QComboBox, say MyClass::MyEnum. But when I tried to get this data using QComboBox::itemData(UserRole), I cannot convert it to this enum. I read the docs and add Q_ENUMS(MyEnum) in myclass.h, but it doesn't work. The enum is only a util class's data, there is no need to set it as a property, how should I do if I want to convert QVariant to custom enum?

ChrisW67
25th December 2010, 22:23
Look up Q_DECLARE_METATYPE in QMetaType