1、概述
源码放在文章末尾
改项目实现了基于PathView,Qt/QML做的一个可以无限滚动的日历控件,下面是demo演示:
项目部分代码如下所示:
import QtQuick 2.7
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4Button {width: 100height: 100property var number: 01 //显示的数字property var beClicked:false //是否被点击过property var isPass: true //是否已经过了,用来设置文字的颜色。没过为灰色,不可点击,过了的为白色id: controlText {text: qsTr("" + number)anchors.centerIn: parentfont.pixelSize: 30//如果是“今”:白色/如果color:text=="今"?"white": control.checked?"white":isPass ? "#aaffffff" : "gray"horizontalAlignment: Text.AlignHCenterverticalAlignment: Text.AlignVCenter}style: ButtonStyle {background:Rectangle {anchors.fill: parentopacity: enabled ? 1 : 0.3 //透明度color: control.checked ? "#4975F8" : "#2C2F38"Rectangle {id: rectanglex: 12width: 6height: 6color: "#4975F8"radius: 3anchors.bottom: parent.bottomanchors.bottomMargin: 15anchors.horizontalCenter: parent.horizontalCentervisible:number===""?false:!beClicked}}}onClicked: {if(number!==""){control.checked = true;beClicked = true}}
}