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

源码下载

相关推荐
shylyly_1 分钟前
list的模拟实现
数据结构·c++·链表·迭代器·list·list的模拟实现
Tomorrow'sThinker44 分钟前
Python零基础学习第三天:函数与数据结构
开发语言·windows·python
元媛媛1 小时前
Python - 轻量级后端框架 Flask
开发语言·python·flask
zhengtianzuo1 小时前
006-获取硬件序列号
c++
钢板兽1 小时前
Java后端高频面经——Spring、SpringBoot、MyBatis
java·开发语言·spring boot·spring·面试·mybatis
爱吃柠檬呀1 小时前
《C陷阱与缺陷》读书笔记(一)
c语言·开发语言·算法·《c陷阱与缺陷》·编写程序
行码棋1 小时前
【Python】omegaconf 用法详解
开发语言·python
awonw1 小时前
[java][基础] 悲观锁 vs 乐观锁
java·开发语言
Trouvaille ~1 小时前
【Java篇】数据类型与变量:窥见程序的天地万象
java·开发语言·青少年编程·面向对象·数据类型·基础知识·入门必看
新停浊酒杯2 小时前
Java基础——java8+新特性——方法引用(::)
java·开发语言