0

I have a QMap like this:

QVariantMap dictionary;
dictionary.insert("name", KeywordType::name);

but when I try to retrieve the value of name key as enum KeywordType type, which is KeywordType::name it return none (that's zero in the KeywordType enum):

  qDebug() << dictionary["name"].value<KeywordType>();

How do i fix this?

the enum type is registered to moc, it use:

Q_ENUM(KeywordType)
Q_DECLARE_METATYPE(keywords::KeywordType)

and

 qRegisterMetaType<KeywordType>("KeywordType");

to make know the typeded:

typedef keywords::KeywordType KeywordType;
Jack
  • 16,276
  • 55
  • 159
  • 284

2 Answers2

0

Maybe you should get name value by keywords::name ? If KeywordType is an enum, it's not a namespace or class.

0x35
  • 162
  • 4
0

I didn't find why this isn't working with my enum, so I eneded up doing this:

static_cast<KeywordType>(dictionary["name"].value<int>())
Jack
  • 16,276
  • 55
  • 159
  • 284