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 Calendarモジュールは、QML言語で使用されるJavaScriptのDate型と整合性を取るために、0ベースの月番号を使用します。つまり、Date::getMonth() をそのままメソッドに渡すことができます。月番号を直接扱う場合は、混乱を避けるために以下の列挙値を使うことを強く推奨します。

定数説明
Calendar.January1月 (0)
Calendar.February2月 (1)
Calendar.March3月 (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)

MonthGrid およびCalendarもご参照 ください。

プロパティ文書

from : date

このプロパティは、開始日を保持する。


to : date

このプロパティは終了日を保持します。


メソッド・ドキュメント

int indexOf(Date date)

指定されたdate のモデル・インデックスを返します。


int indexOf(int year, int month)

指定されたyear およびmonth のモデルインデックスを返します。


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.