DayOfWeekRow QML Type

一排星期内的天数名称。更多

Import Statement: import QtQuick.Controls
Inherits:

Control

属性

详细说明

DayOfWeekRow 按行显示星期名称。天数名称使用指定的locale 进行排序和格式化。

DayOfWeekRow {
    locale: Qt.locale("en_US")
}

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

ColumnLayout {
    DayOfWeekRow {
        locale: grid.locale
        Layout.fillWidth: true
    }

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

DayOfWeekRow 的可视化外观可通过实施custom delegate 进行更改。

另请参见 MonthGridWeekNumberColumn

属性文档

delegate : Component

该属性包含可视化一周中每一天的项目委托。

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

model.day: int星期几 (Qt::DayOfWeek)
model.longName:字符串日名称的长版本;例如,"Monday" (QLocale::LongFormat)
model.shortName:字符串日名的简短版本;例如,"Mon" (QLocale::ShortFormat)
model.窄名:字符串在空间有限的情况下使用的特殊版本的日期名称。例如,"M" (QLocale::NarrowFormat)

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

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

    required property string shortName
}

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