《QT实用小工具·三十五》基于PathView,Qt/QML做的一个可以无限滚动的日历控件

1、概述
源码放在文章末尾

改项目实现了基于PathView,Qt/QML做的一个可以无限滚动的日历控件,下面是demo演示:

项目部分代码如下所示:

cpp 复制代码
import QtQuick 2.7
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4

Button {

    width: 100
    height: 100
    property var number: 01 //显示的数字
    property var beClicked:false //是否被点击过
    property var isPass: true //是否已经过了,用来设置文字的颜色。没过为灰色,不可点击,过了的为白色
    id: control


    Text {
        text: qsTr("" + number)
        anchors.centerIn: parent
        font.pixelSize: 30
        //如果是"今":白色/如果
        color:text=="今"?"white": control.checked?"white":isPass ? "#aaffffff" : "gray"
        horizontalAlignment: Text.AlignHCenter
        verticalAlignment: Text.AlignVCenter
    }

    style: ButtonStyle {
        background:Rectangle {
            anchors.fill: parent
            opacity: enabled ? 1 : 0.3 //透明度
            color: control.checked ? "#4975F8" : "#2C2F38"

            Rectangle {
                id: rectangle
                x: 12
                width: 6
                height: 6
                color: "#4975F8"
                radius: 3
                anchors.bottom: parent.bottom
                anchors.bottomMargin: 15
                anchors.horizontalCenter: parent.horizontalCenter
                visible:number===""?false:!beClicked
            }

        }

    }


    onClicked: {
        if(number!==""){
            control.checked = true;
            beClicked = true
        }}
}

源码下载

相关推荐
阿正的梦工坊4 小时前
JavaScript 微任务与宏任务完全指南
开发语言·javascript·ecmascript
知行合一。。。4 小时前
Python--05--面向对象(属性,方法)
android·开发语言·python
自信150413057594 小时前
重生之从0开始学习c++之模板初级
c++·学习
青梅橘子皮5 小时前
C语言---指针的应用以及一些面试题
c语言·开发语言·算法
浅时光_c5 小时前
3 shell脚本编程
linux·开发语言·bash
历程里程碑5 小时前
2. Git版本回退全攻略:轻松掌握代码时光机
大数据·c++·git·elasticsearch·搜索引擎·github·全文检索
极客智造5 小时前
深度解析 C++ 类继承与多态:面向对象编程的核心
c++
Evand J5 小时前
【三维轨迹目标定位,CKF+RTS,MATLAB程序】基于CKF与RTS平滑的三维非线性目标跟踪(距离+方位角+俯仰角)
开发语言·matlab·目标跟踪
今天又在写代码6 小时前
java-v2
java·开发语言
competes7 小时前
慈善基金投资底层逻辑应用 顶层代码低代码配置平台开发结构方式数据存储模块
java·开发语言·数据库·windows·sql