【QView】基于QML的UI组件框架 之 Color(颜色)

在这里插入图片描述

先上结果演示

在这里插入图片描述

环境(不说版本就是耍流氓)

硬件:通用PC / 手机 / Jetson Xavier NX 套件(均测试有效)
系统:Ubuntu 20.04 / Android / Windows (均测试有效)
软件 :基于QT6.2.4 + Qml

功能描述

ColorPage 定义了Error、Warning、Info、Success等颜色。

更多的使用详见**“实例用法”**

属性名称 [类型] (默认值)

实例用法

/******************************************************************************
 * Copyright 2023-Adiemcoin.
 * All right reserved. See COPYRIGHT for detailed Information.
 *
 * @文件       ColorPage.qml
 * @概要       XXXX Function
 *
 * @作者       Adimecoin(QQ:413819260)
 * @e-mail    adimecoin@foxmail.com
 * @创建日期   2023/12/05
 * @修改历史
 *****************************************************************************/
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
Item {
    readonly property color contentColor: "#606266"
    ListModel {
        id:list
        ListElement {
            title: "主色调" ;
            primaryColor: "#3c9cff";darkColor: "#398ade";
            disabledColor: "#9acafc";lightColor:"#ecf5ff";
        }
        ListElement {
            title: "Error" ;
            primaryColor: "#f56c6c";darkColor: "#e45656";
            disabledColor: "#f7b2b2";lightColor:"#fef0f0";
        }
        ListElement {
            title: "Warning" ;
            primaryColor: "#f9ae3d";darkColor: "#f1a532";
            disabledColor: "#f9d39b";lightColor:"#fdf6ec";
        }
        ListElement {
            title: "Info" ;
            primaryColor: "#909399";darkColor: "#767a82";
            disabledColor: "#c4c6c9";lightColor:"#f4f4f5";
        }
        ListElement {
            title: "Success" ;
            primaryColor: "#5ac725";darkColor: "#53c21d";
            disabledColor: "#a9e08f";lightColor:"#f5fff0";
        }
        ListElement {
            title: "文字颜色" ;
            primaryColor: "#303133";darkColor: "#606266";
            disabledColor: "#909399";lightColor:"#fdf6ec";
        }
        ListElement {
            title: "边框颜色" ;
            primaryColor: "#9a9998";darkColor: "#b4b3b1";
            disabledColor: "#ceccca";lightColor:"#e7e6e4";
        }
    }
    ListView{
        anchors.fill: parent
        model: list
        clip: true
        delegate:Rectangle{
            height: 100
            Column{
                Text {
                    text: qsTr(model.title)
                    color: contentColor
                }
                Row{
                    Rectangle {
                        width: 120
                        height: 60
                        color:model.primaryColor
                        radius: 3
                        Column{
                            Text {
                                text: qsTr("原色")
                                color: "white"
                            }
                            Text {
                                text: qsTr(model.primaryColor)
                                color: "white"
                            }
                        }
                    }
                    Rectangle {
                        width: 120
                        height: 60
                        color:model.darkColor
                        radius: 3
                        Column{
                            Text {
                                text: qsTr("暗色")
                                color: "white"
                            }
                            Text {
                                text: qsTr(model.darkColor)
                                color: "white"
                            }
                        }
                    }
                    Rectangle {
                        width: 120
                        height: 60
                        color:model.disabledColor
                        radius: 3
                        Column{
                            Text {
                                text: qsTr("失能")
                                color: "white"
                            }
                            Text {
                                text: qsTr(model.disabledColor)
                                color: "white"
                            }
                        }
                    }
                    Rectangle {
                        width: 120
                        height: 60
                        color:model.lightColor
                        radius: 3
                        Column{
                            Text {
                                text: qsTr("亮色")
                                color: contentColor
                            }
                            Text {
                                text: qsTr(model.lightColor)
                                color: contentColor
                            }
                        }
                    }
                }
            }
        }
    }

}

OK!
至此,问题解决。欢迎留言交流

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值