QtQuick/Qml系列教程

Qml日历

2018-11-29  本文已影响0人  zhengtianzuo

目前显示日历还没有QtQuick.Controls2, 只能用1显示

    Calendar {
        anchors.centerIn: parent

        style: CalendarStyle {
            gridVisible: false
            dayDelegate: Rectangle {
                property bool dayIsValid: dayValid(styleData.date.getDate().toString())

                gradient: Gradient {
                    GradientStop {
                        position: 0.00
                        color: styleData.selected && dayIsValid ? "#148014" : (styleData.visibleMonth && styleData.valid ? (dayIsValid ? "#CCCCCC" : "#FFFFFF") : "#FFFFFF");
                    }
                }

                Label {
                    text: styleData.date.getDate()
                    anchors.centerIn: parent
                }

                Rectangle {
                    width: parent.width
                    height: 1
                    color: "#EEEEEE"
                    anchors.bottom: parent.bottom
                }

                Rectangle {
                    width: 1
                    height: parent.height
                    color: "#EEEEEE"
                    anchors.right: parent.right
                }
            }
        }
    }
show.gif

需要完整代码请访问QtQuickExamples

上一篇 下一篇

猜你喜欢

热点阅读