このページでは

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 コントロールのカレンダー関連型では、JavaScript の Date オブジェクトと同様に、0 から始まる月番号が使用されます。ただし、これは月番号が 1 から始まるQDate とは異なります。

混乱を避けるために、以下の列挙値を使用できます:

定数説明
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` の年数を返します。

© 2026 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.