当前位置:网站首页>QML type: locale, date
QML type: locale, date
2022-07-06 09:10:00 【Friendly, friend】
Locale
One 、 describe
This type provides locale specific properties and formatted data .
Locale The object can only pass through Qt.locale() Function creation . You can't create... Directly .
Qt.locale() The function returns a JS Locale object , Represents the locale with the specified name , The format for “language[_territory][.codeset][@modifier]” or “C”.
Support the concept of default locale , The default locale is determined by the locale of the system when the application starts . If no parameters are passed to Qt.locale(), Return the default locale object .
Two 、 Attribute members
1、amText : string
Use 12 Hour time “AM” Localized name of suffix .
2、decimalPoint : string
Decimal character .
3、exponential : string
Exponential character .
4、firstDayOfWeek : enumeration
The first day of the week .
- Locale.Sunday = 0
- Locale.Monday = 1
- Locale.Tuesday = 2
- Locale.Wednesday = 3
- Locale.Thursday = 4
- Locale.Friday = 5
- Locale.Saturday = 6
5、groupSeparator : string
Group separator .
6、measurementSystem : enumeration
The unit of measurement .
- Locale.MetricSystem: Metric units , For example, rice 、 Centimeters and millimeters .
- Locale.ImperialUSSystem: Imperial units , For example, inches and miles used in the United States .
- Locale.ImperialUKSystem: Imperial units , For example, inches and miles used in Britain .
- Locale.ImperialSystem: Provide compatibility . And Locale.ImperialUSSystem identical .
7、name : string
The language and country of this locale / The region is saved as “language_country” String of form , Among them, the language is two letters of lowercase ISO 639 The language code , Countries are capitalized with two or three letters ISO 3166 Country code .
8、nativeCountryName : string
The local name of the country .
9、nativeLanguageName : string
The local name of the language .
10、negativeSign : string
Negative sign character .
11、numberOptions : enumeration
Contains a set of options for number to string and string to number conversion .
12、percent : string
Percentage characters .
13、pmText : string
Use 12 Hour time “PM” Localized name of suffix .
14、positiveSign : string
Positive sign character .
15、textDirection : enumeration
Text direction of language .
- Qt.LeftToRight
- Qt.RightToLeft
16、uiLanguages : Array<string>
Returns an ordered list of locale names used for translation purposes in order of priority .
The return value indicates that the user wants to see UI Translated locale name .
17、weekDays : Array<int>
The number of days considered as working days according to the current locale , Sunday is 0, Saturday is 6.
18、zeroDigit : string
Zero character .
3、 ... and 、 Member functions
1、string currencySymbol(format)
Returns the currency symbol in the specified format :
- Locale.CurrencyIsoCode: Monetary ISO-4217 Code .
- Locale.CurrencySymbol: Currency symbols .
- Locale.CurrencyDisplayName: Name of currency .
2、string dateFormat(type)
string dateTimeFormat(type)
Returns the date used for the current locale 、 Date time format .type Specifies the FormatType. See... Below Date.
3、string dayName(day, type)
With type Specified optional FormatType Returns the localized name of the day (day Parameters 0 On behalf of Sunday ,1 On behalf of Monday , And so on ).
4、string formattedDataSize(int bytes, int precision, DataSizeFormat format)
Convert byte size to readable localized string . see QLocale::formattedDataSize().
5、string monthName(month, type)
With type Specified optional FormatType Returns the localized name of the month (0-11).
6、string standaloneDayName(day, type)
Returns the localized name of the date used as stand-alone text ( among 0 On behalf of Sunday ,1 On behalf of Monday , And so on ), Using the type designated FormatType.
If locale information does not specify an independent date name , Then the return value is the same as dayName() The same in .
7、string standaloneMonthName(month, type)
Returns the localized name of the month used as stand-alone text (0-11), use type Specified optional FormatType.
If the locale information does not specify an independent month name , Then the return value is the same as monthName() The same in .
8、string timeFormat(type)
Returns the time format used for the current locale .type Specifies the FormatType.
Date
One 、 describe
Date Object usage area (Locale) The setting function is extended JS Date object .
Two 、 Format enumeration values
When you need a format that matches your locale preferences , Use enumeration values :
- Locale.LongFormat: Longer format
- Locale.ShortFormat: Shorter format
- Locale.NarrowFormat: In context with Locale.ShortFormat identical
The format of the enumeration representation will depend on the locale , But it also depends on the method of enumeration .
for example , about en_US Language environment , Use the following format string :

3、 ... and 、 Member functions
1、string fromLocaleDateString(locale, dateString, format)
Use locale and format to put date strings dateString Convert to Date object .
If no format is specified , Will use Locale.LongFormat.
If the locale is not specified , The default locale will be used .
import QtQml 2.0
QtObject {
property var locale: Qt.locale()
property date currentDate: new Date()
property string dateString
Component.onCompleted: {
dateString = currentDate.toLocaleDateString();
print(Date.fromLocaleDateString(dateString));
}
}2、string fromLocaleString(locale, dateTimeString, format)
Use locale and format to put date time strings dateTimeString Convert to Date object .
If no format is specified , Will use Locale.LongFormat.
If the locale is not specified , The default locale will be used .
import QtQml 2.0
QtObject {
property var locale: Qt.locale()
property string dateTimeString: "Tue 2013-09-17 10:56:06"
Component.onCompleted: {
print(Date.fromLocaleString(locale, dateTimeString, "ddd yyyy-MM-dd hh:mm:ss"));
}
}3、string fromLocaleTimeString(locale, timeString, format)
Use locale and format to convert time strings timeString Convert to Date object .
If no format is specified , Will use Locale.LongFormat.
If the locale is not specified , The default locale will be used .
import QtQml 2.2
QtObject {
property var locale: Qt.locale()
property date currentTime: new Date()
property string timeString
Component.onCompleted: {
timeString = currentTime.toLocaleTimeString(locale, Locale.ShortFormat);
print(Date.fromLocaleTimeString(locale, timeString, Locale.ShortFormat));
}
}4、string timeZoneUpdated()
notice JS The time zone of the engine system has changed , This is necessary for correct operation of date and time data .
This function should be called after the system time zone is updated .
The application that changes the time zone will call... After setting the new time zone timeZoneUpdated():
property string selectedTimeZone
onSelectedTimeZoneChanged: {
MyFunctions.setSystemTimeZone(selectedTimeZone)
Date.timeZoneUpdated()
}5、string toLocaleDateString(locale, format)
take Date Converts to a string containing the date of the specified locale in the specified format .
If no format is specified , Will use Locale.LongFormat.
If the locale is not specified , The default locale will be used .
import QtQuick 2.0
Text {
text: "The date is: " + new Date().toLocaleDateString(Qt.locale("de_DE"))
}6、string toLocaleString(locale, format)
take Date Converts to a string containing the date and time of the specified locale in the specified format .
If no format is specified , Will use Locale.LongFormat.
If the locale is not specified , The default locale will be used .
import QtQuick 2.0
Text {
text: "The date is: " + new Date().toLocaleString(Qt.locale("de_DE"))
}7、string toLocaleTimeString(locale, format)
take Date Converts to a string containing the time of the specified locale in the specified format .
If no format is specified , Will use Locale.LongFormat.
If the locale is not specified , The default locale will be used .
import QtQuick 2.0
Text {
text: "The date is: " + new Date().toLocaleTimeString(Qt.locale("de_DE"))
}边栏推荐
- Li Kou daily question 1 (2)
- Using C language to complete a simple calculator (function pointer array and callback function)
- Nacos 的安装与服务的注册
- LeetCode:剑指 Offer 42. 连续子数组的最大和
- [oc]- < getting started with UI> -- common controls uibutton
- [OC]-<UI入门>--常用控件-提示对话框 And 等待提示器(圈)
- Pytest之收集用例规则与运行指定用例
- Using label template to solve the problem of malicious input by users
- 力扣每日一题(二)
- [oc foundation framework] - < copy object copy >
猜你喜欢

数字人主播618手语带货,便捷2780万名听障人士

【文本生成】论文合集推荐丨 斯坦福研究者引入时间控制方法 长文本生成更流畅

Mongodb installation and basic operation

Intel Distiller工具包-量化实现2

SimCLR:NLP中的对比学习
![[MySQL] multi table query](/img/eb/9d54df9a5c6aef44e35c7a63b286a6.jpg)
[MySQL] multi table query
![[oc]- < getting started with UI> -- common controls uibutton](/img/4d/f5a62671068b26ef43f1101981c7bb.png)
[oc]- < getting started with UI> -- common controls uibutton

LeetCode:236. The nearest common ancestor of binary tree

Intel distiller Toolkit - Quantitative implementation 1

Booking of tourism products in Gansu quadrupled: "green horse" became popular, and one room of B & B around Gansu museum was hard to find
随机推荐
[oc]- < getting started with UI> -- learning common controls
go-redis之初始化连接
LeetCode:41. 缺失的第一个正数
Redis之Bitmap
requests的深入刨析及封装调用
使用标签模板解决用户恶意输入的问题
LeetCode:221. 最大正方形
Mise en œuvre de la quantification post - formation du bminf
五层网络体系结构
【文本生成】论文合集推荐丨 斯坦福研究者引入时间控制方法 长文本生成更流畅
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
Alibaba cloud server mining virus solution (practiced)
MongoDB 的安装和基本操作
【剑指offer】序列化二叉树
一篇文章带你了解-selenium工作原理详解
Advanced Computer Network Review(4)——Congestion Control of MPTCP
[OC-Foundation框架]--<Copy对象复制>
Simclr: comparative learning in NLP
LeetCode:673. 最长递增子序列的个数
[OC-Foundation框架]---【集合数组】