ARGB 颜色值。
The
color
类型指 ARGB 颜色值。有许多种方式可以指定:
"#RRGGBB"
and
"#AARRGGBB"
respectively. For example, the color red corresponds to a triplet of
"#FF0000"
and a slightly transparent blue to a quad of
"#800000FF"
.
范例:
Rectangle { color: "steelblue" width: 40; height: 40 } Rectangle { color: "transparent" y: 40; width: 40; height: 40 } Rectangle { color: "#FF0000" y: 80; width: 40; height: 40 } Rectangle { color: "#800000FF" y: 120; width: 40; height: 40 } Rectangle { color: "#00000000" // ARGB fully transparent y: 160 width: 40; height: 40 }
color 类型拥有
r
,
g
,
b
and
a
properties that refer to the red, green, blue and alpha values of the color, respectively. Additionally it has
hsvHue
,
hsvSaturation
,
hsvValue
and
hslHue
,
hslSaturation
,
hslLightness
properties, which allow access to color values in HSV and HSL color models accordingly:
Text { color: "red" // prints "1 0 0 1" Component.onCompleted: console.log(color.r, color.g, color.b, color.a) }
要测试颜色值是否相等,使用 Qt.colorEqual() function. This allows colors to be accurately compared whether they are in property form or in any of the acceptable string specification forms.
集成 C++ 时,注意任何
QColor
值
传入 QML 来自 C++
is automatically converted into a
color
value, and vice-versa.
此基本类型的提供是通过 QtQuick 导入。
另请参阅 QML 基本类型 .