标签:
一、enum 自省
const QMetaObject &mo = [ClassName]::staticMetaObject; int index = mo.indexOfEnumerator("[EnumName]"); QMetaEnum me = mo.enumerator(index);
若 enum 定义在当前类中,则可以简写为
int index = staticMetaObject.indexOfEnumerator("[EnumName]"); QMetaEnum me = staticMetaObject.enumerator(index);
二、enum 转换
1、 enum <-> int
enum Color { Red, White, Blue};
Color c = (Color)1; //c=White
int i = Red; //i=0
2、 enum <-> string
enum Color { Red, White, Blue};
Color c =
QString s =
标签:
原文地址:http://www.cnblogs.com/FindSelf/p/4901520.html