qt5中的enum class ChType { CH1_3 = 1, CH2_3 = 2, CH1_7 = 3, CH2_7 = 4 };转到qt4中如何改?
时间: 2024-05-07 16:19:01 浏览: 89
在 Qt4 中,可以使用普通的枚举(不是枚举类)来代替 enum class,例如:
```cpp
enum ChType {
CH1_3 = 1,
CH2_3 = 2,
CH1_7 = 3,
CH2_7 = 4
};
```
这将定义一个名为 `ChType` 的枚举,其中包含四个值 CH1_3、CH2_3、CH1_7 和 CH2_7。这些值将被分配为整数值1到4。
请注意,在 Qt5 中,使用了 enum class 而不是普通的枚举。这意味着枚举值是强类型的,它们不能被隐式转换为整数类型。如果需要使用枚举值作为整数,必须显式转换。在 Qt4 中,由于使用的是普通的枚举,因此不需要进行此类显式转换。
阅读全文
相关推荐
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)