内容表

上一话题

QChildEvent

下一话题

QCollatorSortKey

QCollator

QCollator class compares strings according to a localized collation algorithm. 更多

Inheritance diagram of PySide2.QtCore.QCollator

New in version 5.2.

概要

函数

详细描述

QCollator is initialized with a QLocale and 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 QCollator object 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.

class QCollator

QCollator(arg__1)

QCollator(locale)

param locale

QLocale

param arg__1

QCollator

构造 QCollator using the system’s default collation locale.

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 ( )
返回类型

QLocale

Returns the locale of the collator.

另请参阅

setLocale()

PySide2.QtCore.QCollator. numericMode ( )
返回类型

bool

返回 true if numeric sorting is enabled, false otherwise.

另请参阅

setNumericMode()

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.

另请参阅

caseSensitivity()

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 .

另请参阅

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.

另请参阅

numericMode()

PySide2.QtCore.QCollator. sortKey ( string )
参数

string – unicode

返回类型

QCollatorSortKey

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.

PySide2.QtCore.QCollator. swap ( other )
参数

other QCollator

Swaps this collator with other 。此函数非常快,且从不失败。