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

源码下载

相关推荐
越来越无动于衷21 分钟前
JAVA包装类
java·开发语言
Flower#29 分钟前
D. Apple Tree Traversing 【Codeforces Round 1023 (Div. 2)】
c++·算法·图论·dfs
GanGuaGua1 小时前
CSS:盒子模型
开发语言·前端·css·html
忘梓.1 小时前
从父类到子类:C++ 继承的奇妙旅程(2)
java·开发语言·c++
IT信息技术学习圈1 小时前
Python程序打包为EXE文件的全面指南
开发语言·python
进取星辰1 小时前
23、Next.js:时空传送门——React 19 全栈框架
开发语言·javascript·react.js
云和数据.ChenGuang3 小时前
人工智能 机器学习期末考试题
开发语言·人工智能·python·机器学习·毕业设计
我是小伍同学4 小时前
基于卷积神经网络和Pyqt5的猫狗识别小程序
人工智能·python·神经网络·qt·小程序·cnn
lllsure6 小时前
Python基础语法
开发语言·python
zxctsclrjjjcph8 小时前
【高并发内存池】从零到一的项目之centralcache整体结构设计及核心实现
开发语言·数据结构·c++·链表