QMetaEnum用来代表枚举信息,内部也是访问moc文件。从moc文件中得到对应值
需要在头文件中声明 Q_ENUM,如下红框部分
moc中qt_meta_stringdata_XTest变为:
qt_meta_data_XTest变为
static const uint qt_meta_data_XTest[] = {
// content:
8, // revision
0, // classname
1, 14, // classinfo
5, 16, // methods
1, 59, // properties
1, 63, // enums/sets
0, 0, // constructors
0, // flags
2, // signalCount
// classinfo: key, value
1, 2,
// signals: name, argc, parameters, tag, flags
3, 1, 46, 4, 0x06 /* Public */,
6, 0, 49, 4, 0x06 /* Public */,
// slots: name, argc, parameters, tag, flags
7, 1, 50, 4, 0x0a /* Public */,
10, 1, 53, 4, 0x0a /* Public */,
13, 1, 56, 4, 0x8a /* Public | MethodRevisioned */,
// signals: revision
0,
0,
// slots: revision
0,
0,
1,
// signals: parameters
QMetaType::Void, QMetaType::VoidStar, 5,
QMetaType::Void,
// slots: parameters
QMetaType::Void, 0x80000000 | 8, 9,
QMetaType::Void, 0x80000000 | 11, 12,
QMetaType::Void, 0x80000000 | 14, 15,
// properties: name, type, flags
16, QMetaType::Bool, 0x00495103,
// properties: notify_signal_id
1,
// enums: name, alias, flags, count, data
17, 17, 0x0, 4, 68,
// enum data: key, value
18, uint(XTest::High),
19, uint(XTest::Low),
20, uint(XTest::VeryHigh),
21, uint(XTest::VeryLow),
0 // eod
};