WeekNumberColumn QML Type

一列周数。更多

Import Statement: import QtQuick.Controls
Inherits:

Control

属性

详细说明

WeekNumberColumn 在一列中显示周数。周数是为给定的monthyear 计算的,使用指定的locale

WeekNumberColumn {
    month: Calendar.December
    year: 2015
    locale: Qt.locale("en_US")
}

WeekNumberColumn 可作为独立控件使用,但最常与MonthGrid 结合使用。无论使用哪种情况,列的定位均由用户自行决定。

RowLayout {
    WeekNumberColumn {
        month: grid.month
        year: grid.year
        locale: grid.locale
        Layout.fillHeight: true
    }

    MonthGrid {
        id: grid
        month: Calendar.December
        year: 2015
        locale: Qt.locale("en_US")
        Layout.fillHeight: true
    }
}

WeekNumberColumn的可视化外观可通过实现custom delegate

另请参见 MonthGridDayOfWeekRow

属性文档

delegate : Component

该属性包含可视化每个周数的项目委托。

除了index 属性外,在每个委托的上下文中还有一个模型数据角色列表:

model.weekNumber: int周数

以下代码段介绍了 item 委托的默认实现。它可以作为实现自定义委托的起点。

delegate: Text {
    text: weekNumber
    font: control.font
    horizontalAlignment: Text.AlignHCenter
    verticalAlignment: Text.AlignVCenter

    required property int weekNumber
}

month : int

此属性用于保存计算周数的月份数。默认值为当前月份。

日历相关类型在 Qt Quick Controls中的日历相关类型使用基于 0 的月份编号,就像 JavaScript Date 对象一样。不过,这与QDate 不同,后者的月份编号从 1 开始。

为避免混淆,可以使用以下枚举值:

常量描述
Calendar.January一月 (0)
Calendar.February二月 (1)
Calendar.March三月 (2)
Calendar.April四月 (3)
Calendar.May五月 (4)
Calendar.June六月 (5)
Calendar.July七月 (6)
Calendar.August八月 (7)
Calendar.September九月 (8)
Calendar.October十月 (9)
Calendar.November十一月 (10)
Calendar.December十二月 (11)

另请参见 Calendar


year : int

该属性用于保存计算星期数的年份数字。

该值必须在-271820275759 的范围内。默认值为当前年份。


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