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

源码下载

相关推荐
不想写代码的星星12 小时前
std::function 详解:用法、原理与现代 C++ 最佳实践
c++
Felix_One1 天前
Qt 串口通信避坑指南:QSerialPort 的 5 个常见问题
qt
樱木Plus2 天前
深拷贝(Deep Copy)和浅拷贝(Shallow Copy)
c++
blasit4 天前
笔记:Qt C++建立子线程做一个socket TCP常连接通信
c++·qt·tcp/ip
肆忆_5 天前
# 用 5 个问题学懂 C++ 虚函数(入门级)
c++
不想写代码的星星5 天前
虚函数表:C++ 多态背后的那个男人
c++
端平入洛7 天前
delete又未完全delete
c++
端平入洛8 天前
auto有时不auto
c++
郑州光合科技余经理9 天前
代码展示:PHP搭建海外版外卖系统源码解析
java·开发语言·前端·后端·系统架构·uni-app·php
feifeigo1239 天前
matlab画图工具
开发语言·matlab