CalendarModel QML Type

캘린더 모델입니다. 더 보기...

Import Statement: import QtQuick.Controls

속성

방법

상세 설명

CalendarModel은 다양한 MonthGrid 인스턴스를 생성하는 방법을 제공합니다. 일반적으로 MonthGrid 을 델리게이트로 사용하는 ListView 의 모델로 사용됩니다.

ListView {
    id: listview

    width: 200; height: 200
    snapMode: ListView.SnapOneItem
    orientation: ListView.Horizontal
    highlightRangeMode: ListView.StrictlyEnforceRange

    model: CalendarModel {
        from: new Date(2015, 0, 1)
        to: new Date(2015, 11, 31)
    }

    delegate: MonthGrid {
        width: listview.width
        height: listview.height

        month: model.month
        year: model.year
        locale: Qt.locale("en_US")
    }

    ScrollIndicator.horizontal: ScrollIndicator { }
}

index 속성 외에도 각 델리게이트의 컨텍스트에서 모델 데이터 역할 목록을 사용할 수 있습니다:

model.month: int월의 숫자
model.year: int연도 번호

의 달력 관련 유형은 Qt Quick Controls 의 달력 관련 타입은 JavaScript Date 객체처럼 0을 기준으로 한 월 번호를 사용합니다. 그러나 이는 월이 1부터 번호가 매겨지는 QDate 와는 다릅니다.

혼동을 피하기 위해 다음 열거형 값을 사용할 수 있습니다:

상수설명
Calendar.January1월 (0)
Calendar.February2월 (1)
Calendar.MarchMarch (2)
Calendar.April4월 (3)
Calendar.May5월 (4)
Calendar.June6월 (5)
Calendar.July7월 (6)
Calendar.August8월 (7)
Calendar.September9월 (8)
Calendar.October10월 (9)
Calendar.November11월 (10)
Calendar.December12월 (11)

MonthGridCalendar참조하세요 .

속성 문서

from : date

이 속성은 시작 날짜를 보유합니다.


to : date

이 속성은 종료 날짜를 보유합니다.


메서드 문서

int indexOf(Date date)

지정된 date 의 모델 인덱스를 반환합니다.


int indexOf(int year, int month)

지정된 yearmonth 의 모델 인덱스를 반환합니다.


int monthAt(int index)

지정된 모델 index 의 월 번호를 반환합니다.


int yearAt(int index)

지정된 모델 index 에서 연도 번호를 반환합니다.


© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.