日志
判断 Enum 里的QFlags 属性,不知道行不行。
2018-01-14 16:55
enum SomeEnum { Value1, Value2, Value3 };
Q_DECLARE_OPERATORS_FOR_FLAGS( QFlags <SomeEnum>) // The previous line declares // Q_DECL_CONSTEXPR QFlags<SomeValue> operator|(SomeValue,SomeValue) {...} int someFunction( QFlags <SomeEnum> value) { switch (value) { case SomeEnum::Value1: return 1 ; case SomeEnum::Value2: return 2 ; case SomeEnum::Value1 | SomeEnum::Value3: // Only possible with C++11 and because QFlags operators are constexpr // Previously this line would call // QFlags<SomeValue> operator|(SomeValue,SomeValue) // that would have thrown an error because only compiler constants // are allowed as case satement return 3 ; default : return 0 ; } } |
下一篇: model 里设置背景色和字体颜色等
上一篇: tableview自动适应宽度