New in version 5.2.
def
caseSensitivity
()
def
compare
(s1, len1, s2, len2)
def
compare
(s1, s2)
def
compare
(s1, s2)
def
ignorePunctuation
()
def
locale
()
def
numericMode
()
def
operator()
(s1, s2)
def
setCaseSensitivity
(cs)
def
setIgnorePunctuation
(on)
def
setLocale
(locale)
def
setNumericMode
(on)
def
sortKey
(string)
def
swap
(other)
QCollatoris initialized with aQLocaleand an optional collation strategy. It tries to initialize the collator with the specified values. The collator can then be used to compare and sort strings in a locale dependent fashion.A
QCollatorobject can be used together with template based sorting algorithms such as std::sort to sort a list of QStrings.In addition to the locale and collation strategy, several optional flags can be set that influence the result of the collation.
PySide2.QtCore.QCollator.
caseSensitivity
(
)
¶
CaseSensitivity
Returns case sensitivity of the collator.
另请参阅
PySide2.QtCore.QCollator.
compare
(
s1
,
len1
,
s2
,
len2
)
¶
s1
–
QChar
len1
–
int
s2
–
QChar
len2
–
int
int
这是重载函数。
比较
s1
with
s2
.
len1
and
len2
specify the lengths of the
QChar
arrays pointed to by
s1
and
s2
.
Returns an integer less than, equal to, or greater than zero depending on whether
s1
sorts before, with or after
s2
.
PySide2.QtCore.QCollator.
compare
(
s1
,
s2
)
¶
s1 – unicode
s2 – unicode
int
PySide2.QtCore.QCollator.
compare
(
s1
,
s2
)
¶
s1
–
QStringRef
s2
–
QStringRef
int
PySide2.QtCore.QCollator.
ignorePunctuation
(
)
¶
bool
返回
true
if punctuation characters and symbols are ignored when determining sort order.
PySide2.QtCore.QCollator.
locale
(
)
¶
Returns the locale of the collator.
另请参阅
PySide2.QtCore.QCollator.
numericMode
(
)
¶
bool
返回
true
if numeric sorting is enabled, false otherwise.
另请参阅
PySide2.QtCore.QCollator.
operator
(
)(s1
,
s2
)
¶
s1 – unicode
s2 – unicode
bool
PySide2.QtCore.QCollator.
setCaseSensitivity
(
cs
)
¶
cs
–
CaseSensitivity
Sets the case
sensitivity
of the collator.
另请参阅
PySide2.QtCore.QCollator.
setIgnorePunctuation
(
on
)
¶
on
–
bool
若
on
is set to true, punctuation characters and symbols are ignored when determining sort order.
The default is locale dependent.
注意
This method is not currently supported if Qt is configured to not use ICU on Linux.
另请参阅
PySide2.QtCore.QCollator.
setLocale
(
locale
)
¶
locale
–
QLocale
Sets the locale of the collator to
locale
.
另请参阅
PySide2.QtCore.QCollator.
setNumericMode
(
on
)
¶
on
–
bool
Enables numeric sorting mode when
on
is set to true.
This will enable proper sorting of numeric digits, so that e.g. 100 sorts after 99.
By default this mode is off.
另请参阅
PySide2.QtCore.QCollator.
sortKey
(
string
)
¶
string – unicode
Returns a for
string
.
Creating the sort key is usually somewhat slower, than using the
compare()
methods directly. But if the string is compared repeatedly (e.g. when sorting a whole list of strings), it’s usually faster to create the sort keys for each string and then sort using the keys.
注意
Not supported with the C (a.k.a. POSIX) locale on Darwin.