如何在 QML 中操作颜色
How to manipulate colors in QML
我想做这样的事情:
Item {
property color primary_color
Rectangle {
color: Qt.rgba(primary_color.red/2, primary_color.green, primary_color.blue, primary_color.alpha<0.5?0.25:0.75)
}
}
但是我怎样才能访问属性?
来自 http://doc.qt.io/qt-5/qml-color.html 文档:
A color type has 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:
Item {
property color primary_color
Rectangle {
color: Qt.rgba(primary_color.r/2, primary_color.g, primary_color.b, primary_color.a<0.5?0.25:0.75)
}
}
我想做这样的事情:
Item {
property color primary_color
Rectangle {
color: Qt.rgba(primary_color.red/2, primary_color.green, primary_color.blue, primary_color.alpha<0.5?0.25:0.75)
}
}
但是我怎样才能访问属性?
来自 http://doc.qt.io/qt-5/qml-color.html 文档:
A color type has 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:
Item {
property color primary_color
Rectangle {
color: Qt.rgba(primary_color.r/2, primary_color.g, primary_color.b, primary_color.a<0.5?0.25:0.75)
}
}