gpt4 book ai didi

qt - 如何在 QML 中操作颜色

转载 作者:行者123 更新时间:2023-12-02 17:09:21 25 4
gpt4 key购买 nike

我想做这样的事情:

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)
}
}

关于qt - 如何在 QML 中操作颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50040756/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com