Qt学习 第22节:Qcolor 中的Alpha不透明度

QColor::QColor(int r, int g, int b, int a = ...)

Constructs a color with the RGB value r, g, b, and the alpha-channel (transparency) value of a.

color对象里头的alpha其实是指不透明度,其值范围为0-255,越大越不透明。
其通常对应opacity,这个就是单词语义表达的不透明度,其值范围[0,1.0f],值越大,越不透明。 

opacity与alpha的映射

100% — FF
95% — F2
90% — E6
85% — D9
80% — CC
75% — BF
70% — B3
65% — A6
60% — 99
55% — 8C
50% — 80
45% — 73
40% — 66
35% — 59
30% — 4D
25% — 40
20% — 33
15% — 26
10% — 1A
5% — 0D
0% — 00
int alpha = Math.round(opacity * 255);
String hex = Integer.toHexString(alpha).toUpperCase();
if (hex.length() == 1){
    hex = "0" + hex;
}

Qt::GlobalColor

 The QColor class provides colors based on RGB, HSV or CMYK values.

ConstantValueDescription
Qt::white3White (#ffffff)
Qt::black2Black (#000000)
Qt::red7Red (#ff0000)
Qt::darkRed13Dark red (#800000)
Qt::green8Green (#00ff00)
Qt::darkGreen14Dark green (#008000)
Qt::blue9Blue (#0000ff)
Qt::darkBlue15Dark blue (#000080)
Qt::cyan10Cyan (#00ffff)
Qt::darkCyan16Dark cyan (#008080)
Qt::magenta11Magenta (#ff00ff)
Qt::darkMagenta17Dark magenta (#800080)
Qt::yellow12Yellow (#ffff00)
Qt::darkYellow18Dark yellow (#808000)
Qt::gray5Gray (#a0a0a4)
Qt::darkGray4Dark gray (#808080)
Qt::lightGray6Light gray (#c0c0c0)
Qt::transparent19a transparent black value (i.e., QColor(0, 0, 0, 0))
Qt::color000 pixel value (for bitmaps)
Qt::color111 pixel value (for bitmaps)

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值