QCollatorSortKey Class

QCollatorSortKey 类可用于加速字符串校对。更多

头文件: #include <QCollatorSortKey>
CMake: find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core

注意:该类中的所有函数都是可重入的

公共函数

QCollatorSortKey(const QCollatorSortKey &other)
(since 6.8) QCollatorSortKey(QCollatorSortKey &&other)
~QCollatorSortKey()
int compare(const QCollatorSortKey &otherKey) const
void swap(QCollatorSortKey &other)
QCollatorSortKey &operator=(QCollatorSortKey &&other)
QCollatorSortKey &operator=(const QCollatorSortKey &other)
bool operator<(const QCollatorSortKey &lhs, const QCollatorSortKey &rhs)

详细描述

QCollatorSortKey 类总是由QCollator::sortKey() 创建,用于快速整理字符串,例如在整理多个字符串时。

另请参见 QCollator,QCollator::sortKey() 和compare()。

成员函数文档

QCollatorSortKey::QCollatorSortKey(const QCollatorSortKey &other)

构建other 整理器密钥的副本。

[noexcept, since 6.8] QCollatorSortKey::QCollatorSortKey(QCollatorSortKey &&other)

移动-从other 构建一个新的 QCollatorSortKey。

注意: moved-from 对象other 处于部分形成状态,其中唯一有效的操作是销毁和赋一个新值。

此函数在 Qt 6.8 中引入。

[noexcept] QCollatorSortKey::~QCollatorSortKey()

销毁校对键。

int QCollatorSortKey::compare(const QCollatorSortKey &otherKey) const

将此键与otherKey 进行比较,后者必须是由与此键相同的QCollator'sortKey() 创建的。比较按照QCollator 的排序顺序进行。

如果此键排序在otherKey 之前,则返回负值;如果两个键相等,则返回 0;如果此键排序在otherKey 之后,则返回正值。

另请参阅 operator<() 。

[noexcept] void QCollatorSortKey::swap(QCollatorSortKey &other)

other 交换此整理器键。这一操作非常快速,从未出现过故障。

[noexcept] QCollatorSortKey &QCollatorSortKey::operator=(QCollatorSortKey &&other)

移动--将other 赋值给此QCollatorSortKey 实例。

注意: 从移动对象other 将处于部分形成状态,其中唯一有效的操作是销毁和赋新值。

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

为该校对键指定other

相关非会员

bool operator<(const QCollatorSortKey &lhs, const QCollatorSortKey &rhs)

两个键必须由同一个QCollator 的 sortKey() 创建。如果lhs 应在rhs 之前排序,则根据创建它们的QCollator 返回true ;否则返回false

另请参阅 QCollatorSortKey::compare() 。

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.