当前位置:网站首页>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"))
}
边栏推荐
- [OC foundation framework] - [set array]
- 一篇文章带你了解-selenium工作原理详解
- Multivariate cluster analysis
- LeetCode:剑指 Offer 48. 最长不含重复字符的子字符串
- UML图记忆技巧
- LeetCode:41. Missing first positive number
- LeetCode41——First Missing Positive——hashing in place & swap
- 【图的三大存储方式】只会用邻接矩阵就out了
- Digital people anchor 618 sign language with goods, convenient for 27.8 million people with hearing impairment
- ant-design的走马灯(Carousel)组件在TS(typescript)环境中调用prev以及next方法
猜你喜欢
A convolution substitution of attention mechanism
[oc]- < getting started with UI> -- common controls - prompt dialog box and wait for the prompt (circle)
Mongodb installation and basic operation
Simclr: comparative learning in NLP
Once you change the test steps, write all the code. Why not try yaml to realize data-driven?
LeetCode:124. Maximum path sum in binary tree
Advanced Computer Network Review(4)——Congestion Control of MPTCP
Advance Computer Network Review(1)——FatTree
I-BERT
postman之参数化详解
随机推荐
LeetCode:26. Remove duplicates from an ordered array
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
Selenium+pytest automated test framework practice
Selenium+Pytest自动化测试框架实战
【图的三大存储方式】只会用邻接矩阵就out了
LeetCode:34. Find the first and last positions of elements in a sorted array
LeetCode:498. Diagonal traversal
数字人主播618手语带货,便捷2780万名听障人士
[OC]-<UI入门>--常用控件的学习
CUDA realizes focal_ loss
go-redis之初始化連接
[MySQL] multi table query
[Hacker News Weekly] data visualization artifact; Top 10 Web hacker technologies; Postman supports grpc
[text generation] recommended in the collection of papers - Stanford researchers introduce time control methods to make long text generation more smooth
Advanced Computer Network Review(3)——BBR
UML diagram memory skills
What is an R-value reference and what is the difference between it and an l-value?
[today in history] February 13: the father of transistors was born The 20th anniversary of net; Agile software development manifesto was born
Alibaba cloud server mining virus solution (practiced)
[OC-Foundation框架]-<字符串And日期与时间>