Calendar of multiple controls under QML2.0

Source: Internet
Author: User
ImportStatement: spanstylewhite-space: prespanimportQtQuick. Controls1.2Since: spanstylewhite-space: prespanQt5.3Inherits: spanstylewhite-space: Role: intframeVisible: boolmaximumDate: date

Import Statement: span style = white-space: pre/span import QtQuick. controls 1.2 Since: span style = white-space: pre/span Qt 5.3 Inherits: span style = white-space: pre/spanFocusScope PropertiesdayOfWeekFormat: intframeVisible: boolmaximumDate: date

Import Statement:
import QtQuick.Controls 1.2Since: Qt 5.3Inherits:FocusScope
PropertiesdayOfWeekFormat : intframeVisible : boolmaximumDate : dateminimumDate : dateselectedDate : datestyle : ComponentvisibleMonth : intvisibleYear : intweekNumbersVisible : boolSignalsclicked(date date)doubleClicked(date date)hovered(date date)pressed(date date)released(date date)MethodsshowNextMonth()showNextYear()showPreviousMonth()showPreviousYear()

The calendar control is based on Qt5.x and above and needs to be imported to QtQuick. Controls.1.2 for use.

The calendar control mainly uses three style settings.

Use style: CalendarStyle

Background: Component
Control: Calendar
DayDelegate: Component
DayOfWeekDelegate: Component
GridColor: color
GridVisible: bool
NavigationBar: Component
WeekNumberDelegate: Component

DayDelegate mainly sets the date style.

DayOfWeekDelegate mainly sets the weekly Style

NavigationBar mainly sets the style for selecting a month in the navigation bar

Background mainly sets the background Style

The following shows how the example is used.

Calendar {id: calendar width: parent. width * 0.6-row. spacing/2 height: parent. height selectedDate: new Date () focus: true style: CalendarStyle {dayDelegate: Rectangle {// set the Date style. The gradient Gradient: gradient {GradientStop {position: 0.00 color: styleData. selected? "#111": (styleData. visibleMonth & styleData. valid? "#444": "#666");} GradientStop {position: 1.00 color: styleData. selected? "#444": (styleData. visibleMonth & styleData. valid? "#111": "#666");} GradientStop {position: 1.00 color: styleData. selected? "#777": (styleData. visibleMonth & styleData. valid? "#111": "#666") ;}} Label {text: styleData. date. getDate () anchors. centerIn: parent color: styleData. valid? "White": "gray"} Rectangle {width: parent. width height: 1 color: "#555" anchors. bottom: parent. bottom} Rectangle {width: 1 height: parent. height color: "#555" anchors. right: parent. right} dayOfWeekDelegate: Item {// set the weekly style Rectangle {anchors. fill: parent Text {id: weekTxt text: Qt. locale (). dayName (styleData. dayOfWeek, control. dayOfWeekFormat) // converts it to the expression of the week content you want anchors. centerIn: parent color: StyleData. selected? "Green": "gray" }}} navigationBar: Rectangle {// navigation control bar, controls the up and down of a date and other color: "#49A9E3" height: dateText. height * 4 Rectangle {color: Qt. rgba (1, 1, 1, 0.6) height: 1 width: parent. width} Rectangle {anchors. bottom: parent. bottom height: 1 width: parent. width color: "# ddd"} ToolButton {id: previusmonth width: parent. height: width-20 anchors. verticalCenter: parent. verticalCenter anchors. left: parent. left anchors. leftMargin: 40 iconSource: "qrc:/images/left.png" onClicked: control. showpreviusmonth ()} Label {id: dateText text: styleData. title font. pixelSize: 14 font. bold: true horizontalAlignment: Text. alignHCenter verticalAlignment: Text. alignVCenter fontSizeMode: Text. fit anchors. verticalCenter: parent. verticalCenter anchors. left: previusmonth. right anchors. leftMargin: 2 anchors. right: nextMonth. left anchors. rightMargin: 2} ToolButton {id: nextMonth width: 60 height: 53 anchors. verticalCenter: parent. verticalCenter anchors. right: parent. right anchors. rightMargin: 40 iconSource: "qrc:/images/right.png" onClicked: control. showNextMonth () style: ButtonStyle {background: Item {implicitWidth: 25 implicitHeight: 25 }}}}}}
The calendar control needs to be set for these styles. For details, refer to the help document of Qt.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.