在日历qml doc http://doc.qt.io/qt-5/qml-qtquick-controls-calendar.html#dayOfWeekFormat-prop中,我没有看到任何属性来更改firstDayOfWeek。所以我查看calendar.qml(qt 5.7.0的源代码),我看到了一个属性__locale
/*!The locale that this calendar should use to display itself.
Affects how dates and day names are localized, as well as which
day is considered the first in a week.
To set an Australian locale, for example:
\code
locale: Qt.locale("en_AU")
\endcode
The default locale is \c Qt.locale().
*/
property var __locale: Qt.locale()
Qt.locale()创建的对象将具有属性firstDayOfWeek http://doc.qt.io/qt-5/qml-qtqml-locale.html#firstDayOfWeek-prop
我想更改日历的第一天,所以我设置了
Calendar {
id: cal
Component.onCompleted: {
cal.__locale.firstDayOfWeek = Locale.Tuesday;
}
}
但是第一天的周刊并没有改变 谁能告诉我,我做错了什么? 还有其他方法可以在qml中更改日历的firstDayOfWeek吗?
谢谢
答案 0 :(得分:1)
在Qt 5.10中,语言环境属性will be public。在此之前,您可以指定这样的语言环境:
Calendar {
__locale: Qt.locale("en_GB")
}