QCollator Class

The QCollator class compares strings according to a localized collation algorithm. More...

Header: #include <QCollator>
qmake: QT += core
Since: Qt 5.2

This class was introduced in Qt 5.2.

Note: All functions in this class are reentrant.

Public Functions

QCollator(const QCollator &other)
QCollator(const QLocale &locale = QLocale())
QCollator &operator=(const QCollator &other)
~QCollator()
QLocale locale() const
void setLocale(const QLocale &locale)

Detailed Description

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.

Member Function Documentation

QCollator::QCollator(const QCollator &other)

Creates a copy of other.

QCollator::QCollator(const QLocale &locale = QLocale())

Constructs a QCollator from locale. If locale is not specified the system's default locale is used.

See also setLocale().

QCollator &QCollator::operator=(const QCollator &other)

Assigns other to this collator.

QCollator::~QCollator()

Destroys the collator.

QLocale QCollator::locale() const

Returns the locale of the collator.

See also setLocale().

void QCollator::setLocale(const QLocale &locale)

Sets the locale of the collator to locale.

See also locale().