当前位置:网站首页>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]-<UI入门>--常用控件-UIButton
- I-BERT
- MYSQL卸载方法与安装方法
- Problems encountered in connecting the database of the project and their solutions
- LeetCode:剑指 Offer 03. 数组中重复的数字
- Advance Computer Network Review(1)——FatTree
- Leetcode: Sword finger offer 48 The longest substring without repeated characters
- 什么是MySQL?MySql的学习之路是怎样的
- CUDA realizes focal_ loss
- LeetCode:673. Number of longest increasing subsequences
猜你喜欢
Redis之性能指标、监控方式
I-BERT
In depth analysis and encapsulation call of requests
数学建模2004B题(输电问题)
opencv+dlib实现给蒙娜丽莎“配”眼镜
After reading the programmer's story, I can't help covering my chest...
An article takes you to understand the working principle of selenium in detail
Once you change the test steps, write all the code. Why not try yaml to realize data-driven?
[OC]-<UI入门>--常用控件的学习
Nacos 的安装与服务的注册
随机推荐
Mongodb installation and basic operation
Advanced Computer Network Review(3)——BBR
Niuke winter vacation training 6 maze 2
Advanced Computer Network Review(4)——Congestion Control of MPTCP
IJCAI2022论文合集(持续更新中)
Computer graduation design PHP Zhiduo online learning platform
CUDA implementation of self defined convolution attention operator
五层网络体系结构
[OC]-<UI入门>--常用控件-提示对话框 And 等待提示器(圈)
LeetCode:673. 最长递增子序列的个数
KDD 2022 paper collection (under continuous update)
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
Mise en œuvre de la quantification post - formation du bminf
项目连接数据库遇到的问题及解决
LeetCode:498. Diagonal traversal
BMINF的後訓練量化實現
【shell脚本】使用菜单命令构建在集群内创建文件夹的脚本
Multivariate cluster analysis
Redis之五大基础数据结构深入、应用场景
postman之参数化详解