CalendarModel QML Type
Un modelo de calendario. Más...
| Import Statement: | import QtQuick.Controls |
Propiedades
Métodos
- int indexOf(Date date)
- int indexOf(int year, int month)
- int monthAt(int index)
- int yearAt(int index)
Descripción detallada
CalendarModel proporciona una forma de crear un rango de instancias de MonthGrid. Normalmente se utiliza como modelo para un ListView que utiliza MonthGrid como delegado.
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 { } }
Además de la propiedad index, se dispone de una lista de roles de datos del modelo en el contexto de cada delegado:
| model.month: int | El número del mes |
| modelo.año: int | El número del año |
Los tipos relacionados con el calendario en Qt Quick Controls utilizan números de mes basados en 0, como los objetos Date de JavaScript. Sin embargo, esto difiere de QDate, donde los meses se numeran empezando por 1.
Para evitar confusiones, puede utilizar los siguientes valores de enumeración:
| Constante | Descripción |
|---|---|
Calendar.January | Enero (0) |
Calendar.February | Febrero (1) |
Calendar.March | Marzo (2) |
Calendar.April | Abril (3) |
Calendar.May | Mayo (4) |
Calendar.June | Junio (5) |
Calendar.July | Julio (6) |
Calendar.August | Agosto (7) |
Calendar.September | septiembre (8) |
Calendar.October | octubre (9) |
Calendar.November | noviembre (10) |
Calendar.December | diciembre (11) |
Ver también MonthGrid y Calendar.
Documentación sobre la propiedad
from : date
Esta propiedad contiene la fecha de inicio.
to : date
Esta propiedad contiene la fecha de finalización.
Documentación del método
int indexOf(Date date)
Devuelve el índice del modelo especificado date.
int indexOf(int year, int month)
Devuelve el índice del modelo especificado year y month.
int monthAt(int index)
Devuelve el número de mes en el modelo especificado index.
int yearAt(int index)
Devuelve el número de año en el modelo especificado 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.