当前位置:网站首页>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"))
}边栏推荐
- Opencv+dlib realizes "matching" glasses for Mona Lisa
- CSP salary calculation
- LeetCode:162. 寻找峰值
- Niuke winter vacation training 6 maze 2
- In depth analysis and encapsulation call of requests
- [sword finger offer] serialized binary tree
- How to intercept the string correctly (for example, intercepting the stock in operation by applying the error information)
- Booking of tourism products in Gansu quadrupled: "green horse" became popular, and one room of B & B around Gansu museum was hard to find
- Intel Distiller工具包-量化实现1
- postman之参数化详解
猜你喜欢

Redis之性能指标、监控方式

Digital people anchor 618 sign language with goods, convenient for 27.8 million people with hearing impairment

Intel Distiller工具包-量化实现3

Improved deep embedded clustering with local structure preservation (Idec)

Redis之五大基础数据结构深入、应用场景

Cesium draw points, lines, and faces

LeetCode41——First Missing Positive——hashing in place & swap
![[oc foundation framework] - < copy object copy >](/img/62/c04eb2736c2184d8826271781ac7e3.png)
[oc foundation framework] - < copy object copy >

甘肃旅游产品预订增四倍:“绿马”走红,甘肃博物馆周边民宿一房难求

How to intercept the string correctly (for example, intercepting the stock in operation by applying the error information)
随机推荐
【shell脚本】使用菜单命令构建在集群内创建文件夹的脚本
[oc foundation framework] - < copy object copy >
go-redis之初始化連接
LeetCode:26. Remove duplicates from an ordered array
LeetCode:26. 删除有序数组中的重复项
Philosophical enlightenment from single point to distributed
Simclr: comparative learning in NLP
LeetCode:498. Diagonal traversal
使用标签模板解决用户恶意输入的问题
LeetCode:498. 对角线遍历
Advanced Computer Network Review(3)——BBR
什么是MySQL?MySql的学习之路是怎样的
BN folding and its quantification
Niuke winter vacation training 6 maze 2
Compétences en mémoire des graphiques UML
LeetCode:162. Looking for peak
数字人主播618手语带货,便捷2780万名听障人士
自定义卷积注意力算子的CUDA实现
Advanced Computer Network Review(5)——COPE
CUDA实现focal_loss