QStringRef Class
QStringRef 类为 `QString ` 的子字符串提供了一个轻量级封装。更多内容...
| 头文件: | #include <QStringRef> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Core5Compat) target_link_libraries(mytarget PRIVATE Qt6::Core5Compat) |
| qmake: | QT += core5compat |
- 所有成员的列表,包括继承的成员
- QStringRef 属于字符串数据类。
注意:该类中的所有函数均为可重入的。
公共类型
公共函数
| QStringRef() | |
| QStringRef(const QString *string) | |
| QStringRef(const QString *string, qsizetype position, qsizetype length) | |
| QStringRef(const QStringRef &other) | |
| ~QStringRef() | |
| QStringRef | appendTo(QString *string) const |
| const QChar | at(int position) const |
| QChar | back() const |
| QStringRef::const_iterator | begin() const |
| QStringRef::const_iterator | cbegin() const |
| QStringRef::const_iterator | cend() const |
| void | chop(int n) |
| QStringRef | chopped(int len) const |
| void | clear() |
| int | compare(QChar ch, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
| int | compare(QLatin1String other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
| int | compare(const QByteArray &other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
| int | compare(const QString &other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
| int | compare(const QStringRef &other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
| QStringRef::const_iterator | constBegin() const |
| const QChar * | constData() const |
| QStringRef::const_iterator | constEnd() const |
| bool | contains(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
| bool | contains(QChar ch, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
| bool | contains(QLatin1String str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
| bool | contains(QStringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
| bool | contains(const QStringRef &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
| int | count() const |
| int | count(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
| int | count(QChar ch, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
| int | count(const QStringRef &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
| QStringRef::const_reverse_iterator | crbegin() const |
| QStringRef::const_reverse_iterator | crend() const |
| const QChar * | data() const |
| QStringRef::const_iterator | end() const |
| bool | endsWith(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
| bool | endsWith(QChar ch, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
| bool | endsWith(QLatin1String str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
| bool | endsWith(QStringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
| bool | endsWith(const QStringRef &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
| QChar | front() const |
| int | indexOf(QLatin1String str, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
| int | indexOf(const QString &str, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
| int | indexOf(QChar ch, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
| int | indexOf(QStringView str, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
| int | indexOf(const QStringRef &str, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
| bool | isEmpty() const |
| bool | isNull() const |
| bool | isRightToLeft() const |
| int | lastIndexOf(const QString &str, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
| int | lastIndexOf(QChar ch, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
| int | lastIndexOf(QLatin1String str, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
| int | lastIndexOf(QStringView str, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
| int | lastIndexOf(const QStringRef &str, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
| QStringRef | left(int n) const |
| int | length() const |
| int | localeAwareCompare(const QString &other) const |
| int | localeAwareCompare(const QStringRef &other) const |
| QStringRef | mid(int position, int n = -1) const |
| int | position() const |
| QStringRef::const_reverse_iterator | rbegin() const |
| QStringRef::const_reverse_iterator | rend() const |
| QStringRef | right(int n) const |
| int | size() const |
| QList<QStringRef> | split(const QString &sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
| QList<QStringRef> | split(QChar sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
| bool | startsWith(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
| bool | startsWith(QChar ch, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
| bool | startsWith(QLatin1String str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
| bool | startsWith(QStringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
| bool | startsWith(const QStringRef &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
| const QString * | string() const |
| double | toDouble(bool *ok = nullptr) const |
| float | toFloat(bool *ok = nullptr) const |
| int | toInt(bool *ok = nullptr, int base = 10) const |
| QByteArray | toLatin1() const |
| QByteArray | toLocal8Bit() const |
| long | toLong(bool *ok = nullptr, int base = 10) const |
| qlonglong | toLongLong(bool *ok = nullptr, int base = 10) const |
| short | toShort(bool *ok = nullptr, int base = 10) const |
| QString | toString() const |
| uint | toUInt(bool *ok = nullptr, int base = 10) const |
| ulong | toULong(bool *ok = nullptr, int base = 10) const |
| qulonglong | toULongLong(bool *ok = nullptr, int base = 10) const |
| ushort | toUShort(bool *ok = nullptr, int base = 10) const |
| QList<uint> | toUcs4() const |
| QByteArray | toUtf8() const |
| QStringRef | trimmed() const |
| void | truncate(int position) |
| const QChar * | unicode() const |
| bool | operator!=(const char *s) const |
| bool | operator<(const char *s) const |
| bool | operator<=(const char *s) const |
| QStringRef & | operator=(const QString *string) |
| QStringRef & | operator=(const QStringRef &other) |
| bool | operator==(const char *s) const |
| bool | operator>(const char *s) const |
| bool | operator>=(const char *s) const |
| QChar | operator[](int position) const |
静态公共成员
| int | compare(const QStringRef &s1, const QString &s2, Qt::CaseSensitivity cs = Qt::CaseSensitive) |
| int | compare(const QStringRef &s1, QLatin1String s2, Qt::CaseSensitivity cs = Qt::CaseSensitive) |
| int | compare(const QStringRef &s1, const QStringRef &s2, Qt::CaseSensitivity cs = Qt::CaseSensitive) |
| int | localeAwareCompare(const QStringRef &s1, const QString &s2) |
| int | localeAwareCompare(const QStringRef &s1, const QStringRef &s2) |
相关的非成员
| bool | operator<(const QStringRef &s1, const QStringRef &s2) |
| bool | operator<=(const QStringRef &s1, const QStringRef &s2) |
| bool | operator==(QLatin1String s1, const QStringRef &s2) |
| bool | operator==(const QString &s1, const QStringRef &s2) |
| bool | operator==(const QStringRef &s1, const QStringRef &s2) |
| bool | operator>(const QStringRef &s1, const QStringRef &s2) |
| bool | operator>=(const QStringRef &s1, const QStringRef &s2) |
详细说明
QStringRef 提供了QString API 的只读子集。
字符串引用会显式引用string()中具有给定size()的某一部分,起始于特定的position()。调用toString()将返回该数据的副本,该副本为真正的QString 实例。
该类旨在提高对从现有QString 实例中获取的子字符串进行操作时的性能。 QStringRef 通过仅引用原始字符串的一部分,从而避免了标准QString 所带来的内存分配和引用计数开销。这在低级代码(例如解析器中使用的代码)中可能具有优势,但代价是代码可能变得更为复杂。
对于大多数用户而言,使用 QStringRef 代替QString 并无语义上的优势,因为 QStringRef 需要特别注意内存管理问题,这可能会导致代码的编写和维护变得更加复杂。
警告:QStringRef 仅在被引用的字符串存在时才有效。如果原始字符串被删除,该字符串引用将指向一个无效的内存位置。
我们建议您仅在稳定的代码中使用此类,且需通过性能分析明确确认:通过用该类提供的优化子字符串处理机制替代标准字符串操作,确实能够提升性能。
安全注意事项
该类使用int 来存储size()和position()的结果。因此,它无法表示长度超过INT_MAX 或起始偏移量大于该值的字符串片段。尝试引用此类片段将导致未定义行为。 请注意,如果QString 的大小超过INT_MAX ,即使未显式传递大小参数,通过QString 构建的 QStringRef 也会受到影响。
请改用QStringView ,同时请注意其所有权模型比 QStringRef 更宽松。更多详情请参阅移植指南。
另请参阅 《隐式共享类》。
成员类型文档
QStringRef::const_iterator
另请参阅 QStringRef::const_reverse_iterator 。
QStringRef::const_reverse_iterator
另请参阅 QStringRef::const_iterator 。
成员函数文档
[constexpr noexcept] QStringRef::QStringRef()
构建一个空字符串引用。
QStringRef::QStringRef(const QString *string)
创建指向给定string 的字符串引用。
警告:QStringRef 使用int (32 位)来表示其size()。在 Qt 6 中,QString 的大小表示为qsizetype ,对于 64 位构建而言,该值占用 64 位。请确保输入的大小能容纳在 32 位内,否则将引发the behavior is undefined 。
QStringRef::QStringRef(const QString *string, qsizetype position, qsizetype length)
构建一个字符串引用,指向给定string 中由起始位置position 和length (以字符为单位)所指定的字符范围。
警告:此 函数旨在尽可能提高性能,因此不进行边界检查。为确保程序正确性,position 和length 必须描述string 的一个有效子字符串,并且能够表示为int 中的字符。
这意味着起始位置position 必须为正数或 0,且小于string 的长度;而length 必须为正数或 0,但小于字符串长度减去起始位置position 的差值;即,必须同时满足 0 <= position < string->length() 以及 0 <= length <= string->length() - position 这两个条件。
警告: 从 Qt 6.12开始, 此构造函数接受qsizetype 、position 和length 作为参数,而非int 。此举可防止在调用端发生无声窄化。但是,如果传入的值无法用int 表示,仍会导致undefined behavior 。
[implicit] QStringRef::QStringRef(const QStringRef &other)
创建other 字符串引用的一份副本。
[noexcept implicit] QStringRef::~QStringRef()
销毁该字符串引用。
由于该类仅用于引用字符串数据,且不拥有该数据的所有权,因此在实例销毁时不会释放内存。
QStringRef QStringRef::appendTo(QString *string) const
将字符串引用追加到 `string` 中,并返回合并后字符串数据的新引用。
const QChar QStringRef::at(int position) const
返回字符串引用中位于指定索引position 处的字符。
该索引position 必须是字符串中的有效索引位置(即 0 <=position <size())。
QChar QStringRef::back() const
返回字符串中的最后一个字符。与at(size() - 1) 相同。
提供此函数是为了兼容 STL。
警告: 对空字符串调用 此函数将导致未定义行为。
另请参阅 front()、at() 和operator[]()。
QStringRef::const_iterator QStringRef::begin() const
返回一个指向字符串中第一个字符的常量STL 风格迭代器。
另请参阅 cbegin()、constBegin()、end()、constEnd()、rbegin() 以及rend()。
QStringRef::const_iterator QStringRef::cbegin() const
与begin() 相同。
另请参阅 begin()、constBegin()、cend()、constEnd()、rbegin() 以及rend()。
QStringRef::const_iterator QStringRef::cend() const
与end() 相同。
另请参阅 end()、constEnd()、cbegin()、constBegin()、rbegin() 以及rend()。
[noexcept] void QStringRef::chop(int n)
从字符串末尾移除n 个字符。
如果 `n ` 大于或等于 `size()`,则结果为空字符串;如果 `n ` 为负数,则等同于传入零。
另请参阅 QString::chop() 和truncate()。
QStringRef QStringRef::chopped(int len) const
返回该字符串最左侧size() -len 个字符的子字符串引用。
注意: 如果len 为负数或大于size(),则行为 未定义。
另请参阅 endsWith()、left()、right()、mid()、chop() 和truncate()。
void QStringRef::clear()
通过将字符串引用设为空并清空其内容,来清除该字符串引用中的内容。
[static noexcept] int QStringRef::compare(const QStringRef &s1, const QString &s2, Qt::CaseSensitivity cs = Qt::CaseSensitive)
将s1 与s2 进行比较,如果s1 小于s2 ,则返回一个负整数;如果大于s2 ,则返回一个正整数;如果两者相等,则返回零。
如果cs 等于Qt::CaseSensitive ,则比较区分大小写;否则,比较不区分大小写。
[noexcept] int QStringRef::compare(QChar ch, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
将*this 与ch 进行比较,若*this 小于ch ,则返回一个负整数;若大于ch ,则返回一个正整数;若两者相等,则返回零。在此,ch 被解释为长度为一的字符串。
若cs 为Qt::CaseSensitive ,则比较区分大小写;否则,比较不区分大小写。
这是一个重载函数。
[noexcept] int QStringRef::compare(QLatin1String other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
将*this 与other 进行比较,如果*this 小于other ,则返回一个负整数;如果大于other ,则返回一个正整数;如果两者相等,则返回零。
如果cs 等于Qt::CaseSensitive ,则比较区分大小写;否则,比较不区分大小写。
等同于compare(*this, other, cs) 。
这是一个重载函数。
[noexcept] int QStringRef::compare(const QByteArray &other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
将*this 与other 进行比较,如果*this 小于other ,则返回负整数;如果大于other ,则返回正整数;如果两者相等,则返回零。other 的内容被解释为 UTF-8 编码。
如果cs 是Qt::CaseSensitive ,则比较区分大小写;否则,比较不区分大小写。
等同于compare(*this, other, cs) 。
这是一个重载函数。
[noexcept] int QStringRef::compare(const QString &other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
将*this 与other 进行比较,若*this 小于other ,则返回一个负整数;若大于other ,则返回一个正整数;若两者相等,则返回零。
如果cs 等于Qt::CaseSensitive ,则比较区分大小写;否则,比较不区分大小写。
等同于compare(*this, other, cs) 。
这是一个重载函数。
[noexcept] int QStringRef::compare(const QStringRef &other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
将*this 与other 进行比较:若*this 小于other ,则返回负整数;若大于other ,则返回正整数;若两者相等,则返回零。
如果cs 等于Qt::CaseSensitive ,则比较区分大小写;否则,比较不区分大小写。
等同于compare(*this, other, cs) 。
这是一个重载函数。
[static noexcept] int QStringRef::compare(const QStringRef &s1, QLatin1String s2, Qt::CaseSensitivity cs = Qt::CaseSensitive)
将s1 与s2 进行比较,如果s1 小于s2 ,则返回一个负整数;如果大于s2 ,则返回一个正整数;如果两者相等,则返回零。
若cs 等于Qt::CaseSensitive ,则比较区分大小写;否则,比较不区分大小写。
这是一个重载函数。
[static noexcept] int QStringRef::compare(const QStringRef &s1, const QStringRef &s2, Qt::CaseSensitivity cs = Qt::CaseSensitive)
将s1 与s2 进行比较,如果s1 小于s2 ,则返回一个负整数;如果大于s2 ,则返回一个正整数;如果两者相等,则返回零。
若cs 等于Qt::CaseSensitive ,则比较区分大小写;否则,比较不区分大小写。
这是一个重载函数。
QStringRef::const_iterator QStringRef::constBegin() const
与begin() 相同。
另请参阅 begin()、cend()、constEnd()、rbegin() 以及rend()。
const QChar *QStringRef::constData() const
与unicode() 相同。
QStringRef::const_iterator QStringRef::constEnd() const
与end() 相同。
另请参阅 end()、cend()、cbegin()、constBegin()、rbegin() 以及rend()。
bool QStringRef::contains(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
如果该字符串引用中包含字符串str ,则返回true ;否则返回false 。
如果cs 为Qt::CaseSensitive (默认值),则搜索区分大小写;否则,搜索不区分大小写。
bool QStringRef::contains(QChar ch, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
如果该字符串中包含字符ch ,则返回true ;否则返回false 。
如果cs 为Qt::CaseSensitive (默认值),则搜索区分大小写;否则,搜索不区分大小写。
此函数重载了QStringRef::contains()。
bool QStringRef::contains(QLatin1String str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
如果该字符串引用中包含字符串“str ”,则返回“true ”;否则返回“false ”。
如果cs 为Qt::CaseSensitive (默认值),则搜索区分大小写;否则,搜索不区分大小写。
此函数重载了QStringRef::contains()。
[noexcept] bool QStringRef::contains(QStringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
如果该字符串引用中包含字符串视图str ,则返回true ;否则返回false 。
如果cs 为Qt::CaseSensitive (默认),则搜索区分大小写;否则,搜索不区分大小写。
此函数重载了QStringRef::contains()。
bool QStringRef::contains(const QStringRef &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
如果该字符串引用中包含字符串引用str ,则返回true ;否则返回false 。
如果cs 是Qt::CaseSensitive (默认值),则搜索区分大小写;否则,搜索不区分大小写。
此函数重载了QStringRef::contains()。
int QStringRef::count() const
返回字符串引用所指代的字符数。等同于size() 和length()。
int QStringRef::count(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
返回该字符串引用中字符串str 的出现次数(可能存在重叠)。
如果cs 为Qt::CaseSensitive (默认值),则搜索区分大小写;否则,搜索不区分大小写。
另请参阅 QString::count()、contains() 和indexOf()。
int QStringRef::count(QChar ch, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
返回字符ch 在字符串引用中出现的次数。
如果 `cs ` 为 `Qt::CaseSensitive `(默认值),则搜索区分大小写;否则,搜索不区分大小写。
此函数重载了QStringRef::count()。
另请参见 QString::count()、contains() 和indexOf()。
int QStringRef::count(const QStringRef &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
返回字符串引用str 在该字符串引用中出现的次数(可能存在重叠)。
如果 `cs ` 为 `Qt::CaseSensitive `(默认值),则搜索区分大小写;否则,搜索不区分大小写。
此函数重载了QStringRef::count() 函数。
另请参见 QString::count()、contains(),以及indexOf()。
QStringRef::const_reverse_iterator QStringRef::crbegin() const
与rbegin() 相同。
另请参阅 begin()、rbegin() 以及rend()。
QStringRef::const_reverse_iterator QStringRef::crend() const
与rend() 相同。
const QChar *QStringRef::data() const
与unicode() 相同。
QStringRef::const_iterator QStringRef::end() const
返回一个指向列表中最后一个字符之后的虚拟字符的常量STL 风格迭代器。
另请参阅 cbegin()、constBegin()、end()、constEnd()、rbegin() 以及rend()。
bool QStringRef::endsWith(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
如果字符串引用以str 结尾,则返回true ;否则返回false 。
如果cs 为Qt::CaseSensitive (默认值),则搜索区分大小写;否则,搜索不区分大小写。
另请参阅 QString::endsWith() 和startsWith()。
bool QStringRef::endsWith(QChar ch, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
如果字符串引用以ch 结尾,则返回true ;否则返回false 。
如果cs 为Qt::CaseSensitive (默认值),则搜索区分大小写;否则,搜索不区分大小写。
此函数重载了QStringRef::endsWith()。
另请参阅 QString::endsWith() 和endsWith()。
bool QStringRef::endsWith(QLatin1String str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
该函数重载了QStringRef::endsWith()。
另请参阅 QString::endsWith() 和endsWith()。
[noexcept] bool QStringRef::endsWith(QStringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
该函数重载了QStringRef::endsWith()。
另请参阅 QString::endsWith() 和startsWith()。
bool QStringRef::endsWith(const QStringRef &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
该函数重载了QStringRef::endsWith()。
另请参阅 QString::endsWith() 和endsWith()。
QChar QStringRef::front() const
返回字符串中的第一个字符。与at(0) 相同。
提供此函数是为了兼容 STL。
警告: 对空字符串调用 此函数将导致未定义行为。
另请参阅 back()、at() 和operator[]()。
int QStringRef::indexOf(QLatin1String str, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
返回字符串引用中字符串str 首次出现的位置索引,从索引位置from 开始向前搜索。如果未找到str ,则返回 -1。
如果cs 为Qt::CaseSensitive (默认值),则搜索区分大小写;否则,搜索不区分大小写。
如果from 为 -1,则从最后一个字符开始搜索;如果为 -2,则从倒数第二个字符开始搜索,以此类推。
另请参阅 QString::indexOf()、lastIndexOf()、contains() 以及count()。
int QStringRef::indexOf(const QString &str, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
返回字符串引用中字符串str 首次出现的位置索引,从索引位置from 开始向前搜索。如果未找到str ,则返回 -1。
如果cs 为Qt::CaseSensitive (默认值),则搜索区分大小写;否则,搜索不区分大小写。
如果from 为 -1,则从最后一个字符开始搜索;如果为 -2,则从倒数第二个字符开始搜索,依此类推。
另请参阅 QString::indexOf()、lastIndexOf()、contains() 和count()。
int QStringRef::indexOf(QChar ch, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
返回字符ch 在字符串引用中首次出现的位置索引,从索引位置from 开始向前搜索。如果未找到ch ,则返回-1。
此函数重载了QStringRef::indexOf()。
另请参阅 QString::indexOf()、lastIndexOf()、contains() 和count()。
[noexcept] int QStringRef::indexOf(QStringView str, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
返回字符串引用中字符串视图str 的首次出现位置,从索引位置from 开始向前搜索。如果未找到str ,则返回 -1。
如果cs 为Qt::CaseSensitive (默认值),则搜索区分大小写;否则,搜索不区分大小写。
如果from 为 -1,则从最后一个字符开始搜索;如果为 -2,则从倒数第二个字符开始搜索,以此类推。
此函数重载了QStringRef::indexOf()。
另请参阅 QString::indexOf()、QStringView::indexOf()、lastIndexOf()、contains() 以及count()。
int QStringRef::indexOf(const QStringRef &str, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
返回字符串引用str 在该字符串引用中首次出现的位置索引,从索引位置from 开始向前搜索。如果未找到str ,则返回 -1。
如果cs 为Qt::CaseSensitive (默认值),则搜索区分大小写;否则,搜索不区分大小写。
此函数重载了QStringRef::indexOf()。
另请参阅 QString::indexOf()、lastIndexOf()、contains() 和count()。
bool QStringRef::isEmpty() const
如果字符串引用中没有字符,则返回true ;否则返回false 。
如果字符串引用的大小为零,则该字符串引用为空。
另请参阅 size()。
bool QStringRef::isNull() const
如果该字符串引用未引用任何字符串,或者其引用的字符串为空(即 `QString::isNull()` 返回 true),则返回 `true `。
另请参阅 size()。
bool QStringRef::isRightToLeft() const
如果字符串是从右向左阅读的,则返回true 。
另请参阅 QString::isRightToLeft()。
int QStringRef::lastIndexOf(const QString &str, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
返回字符串引用中字符串str 的最后一次出现位置,从索引位置from 开始向后搜索。如果from 为 -1(默认值),则从最后一个字符开始搜索;如果from 为 -2,则从倒数第二个字符开始搜索,依此类推。如果未找到str ,则返回 -1。
如果cs 为Qt::CaseSensitive (默认值),则搜索区分大小写;否则,搜索不区分大小写。
另请参阅 QString::lastIndexOf()、indexOf()、contains() 以及count()。
int QStringRef::lastIndexOf(QChar ch, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
返回字符ch 的最后一次出现位置,从位置from 开始向后搜索。
此函数重载了QStringRef::lastIndexOf()。
另请参阅 QString::lastIndexOf()、indexOf()、contains() 和count()。
int QStringRef::lastIndexOf(QLatin1String str, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
返回字符串引用中字符串str 的最后一次出现位置的索引,从索引位置from 开始向后搜索。如果from 为 -1(默认),则从最后一个字符开始搜索;如果from 为 -2,则从倒数第二个字符开始搜索,依此类推。如果未找到str ,则返回 -1。
若cs 的值为Qt::CaseSensitive (默认值),则搜索区分大小写;否则不区分大小写。
此函数重载了QStringRef::lastIndexOf()。
另请参阅 QString::lastIndexOf()、indexOf()、contains(),以及count()。
[noexcept] int QStringRef::lastIndexOf(QStringView str, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
返回字符串中字符串视图str 的最后一次出现位置,从索引位置from 开始向后搜索。如果from 为 -1(默认值),则从最后一个字符开始搜索;如果from 为 -2,则从倒数第二个字符开始搜索,依此类推。如果未找到str ,则返回 -1。
若cs 的值为Qt::CaseSensitive (默认值),则搜索区分大小写;否则不区分大小写。
此函数重载了QStringRef::lastIndexOf()。
另请参阅 indexOf()、contains() 和count()。
int QStringRef::lastIndexOf(const QStringRef &str, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
返回在此字符串引用中,字符串引用str 的最后一次出现位置的索引,从索引位置from 开始向后搜索。如果from 为 -1(默认值),则从最后一个字符开始搜索;如果from 为 -2,则从倒数第二个字符开始搜索,依此类推。如果未找到str ,则返回 -1。
若cs 的值为Qt::CaseSensitive (默认),则搜索区分大小写;否则不区分大小写。
此函数重载了QStringRef::lastIndexOf()。
另请参阅 QString::lastIndexOf()、indexOf()、contains() 和count()。
QStringRef QStringRef::left(int n) const
返回字符串最左侧n 个字符的子字符串引用。
如果 `n ` 大于或等于 `size()`,或者小于零,则返回对整个字符串的引用。
另请参阅 right()、mid()、startsWith()、chopped()、chop() 和truncate()。
int QStringRef::length() const
返回字符串引用所指代的字符数。等同于size() 和count()。
[static] int QStringRef::localeAwareCompare(const QStringRef &s1, const QString &s2)
比较s1 与s2 ,如果s1 小于s2 ,则返回一个负整数;如果大于s2 ,则返回一个正整数;如果两者相等,则返回零。
比较操作受区域设置和平台的影响。使用此函数可向用户呈现按顺序排序的字符串列表。
另请参阅 compare()、QLocale 以及Comparing Strings 。
int QStringRef::localeAwareCompare(const QString &other) const
比较*this 与other ,如果*this 小于other ,则返回一个负整数;如果大于other ,则返回一个正整数;如果两者相等,则返回零。
比较操作既取决于区域设置,也取决于平台。使用此函数可向用户展示按顺序排列的字符串列表。
这是一个重载函数。
另请参阅 Comparing Strings 。
int QStringRef::localeAwareCompare(const QStringRef &other) const
比较*this 与other ,如果*this 小于other ,则返回一个负整数;如果大于other ,则返回一个正整数;如果两者相等,则返回零。
比较操作既取决于区域设置,也取决于平台。使用此函数可向用户呈现按顺序排序的字符串列表。
这是一个重载函数。
另请参阅 Comparing Strings 。
[static] int QStringRef::localeAwareCompare(const QStringRef &s1, const QStringRef &s2)
比较s1 与s2 ,若s1 小于s2 ,则返回负整数;若大于s2 ,则返回正整数;若两者相等,则返回零。
比较操作既取决于区域设置,也取决于平台。使用此函数可向用户呈现按顺序排列的字符串列表。
这是一个重载函数。
另请参阅 Comparing Strings 。
QStringRef QStringRef::mid(int position, int n = -1) const
返回该字符串中从指定位置position 开始的n 个字符的子字符串引用。
如果该position 超出了字符串的长度,则返回一个空引用。
如果生成的position() 无法用int 表示,则返回一个 nullQStringRef 。
如果从给定的position 开始,字符串中可用的n 字符少于该数值,或者n 为 -1(默认值),则该函数将返回从指定的position 开始的所有字符。
另请参阅 left()、right()、chopped()、chop() 以及truncate()。
int QStringRef::position() const
返回字符串引用所指向的字符串中的起始位置。
QStringRef::const_reverse_iterator QStringRef::rbegin() const
返回一个指向字符串中第一个字符(按反向顺序)的常量STL 风格反向迭代器。
另请参见 begin()、crbegin() 和rend()。
QStringRef::const_reverse_iterator QStringRef::rend() const
返回一个STL 风格的反向迭代器,该迭代器指向字符串中最后一个字符之后的一个位置,且顺序为反向。
QStringRef QStringRef::right(int n) const
返回字符串中n 个最右侧字符的子字符串引用。
如果 `n ` 大于或等于 `size()`,或者小于零,则返回整个字符串的引用。
如果新的position() 无法用int() 表示,则返回整个字符串的引用。
另请参阅 left()、mid()、endsWith()、chopped()、chop() 以及truncate()。
int QStringRef::size() const
返回字符串引用所指向的字符数。等同于length() 和count()。
QList<QStringRef> QStringRef::split(const QString &sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
将字符串拆分为子字符串,其中包含所有sep 的出现位置,并返回这些字符串的列表。
有关 `sep`、`behavior ` 和 `cs ` 如何协同作用形成结果,请参阅 `QString::split()`。
注意: 只要该字符串存在,所有 引用都是有效的。销毁该字符串将导致所有引用变成悬空指针。
QList<QStringRef> QStringRef::split(QChar sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
这是一个重载函数。
bool QStringRef::startsWith(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
如果字符串引用以str 开头,则返回true ;否则返回false 。
如果cs 为Qt::CaseSensitive (默认值),则搜索区分大小写;否则,搜索不区分大小写。
另请参阅 QString::startsWith() 和endsWith()。
bool QStringRef::startsWith(QChar ch, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
如果字符串引用以ch 开头,则返回true ;否则返回false 。
如果cs 为Qt::CaseSensitive (默认值),则搜索区分大小写;否则,搜索不区分大小写。
此函数重载了QStringRef::startsWith()。
另请参阅 QString::startsWith() 和endsWith()。
bool QStringRef::startsWith(QLatin1String str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
该函数重载了QStringRef::startsWith()。
另请参阅 QString::startsWith() 和endsWith()。
[noexcept] bool QStringRef::startsWith(QStringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
该函数重载了 `QStringRef::startsWith()`。
另请参阅 ` QString::startsWith()` 和 `endsWith()`。
bool QStringRef::startsWith(const QStringRef &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
该函数重载了QStringRef::startsWith()。
另请参阅 QString::startsWith() 和endsWith()。
const QString *QStringRef::string() const
返回指向字符串引用所引用的字符串的指针;如果该引用未引用任何字符串,则返回 0。
另请参阅 ` unicode()`。
double QStringRef::toDouble(bool *ok = nullptr) const
返回已转换为double 值的字符串。
如果转换发生溢出,则返回无穷大;如果因其他原因(例如下溢)导致转换失败,则返回 0.0。
如果 `ok ` 不是 `nullptr`,则通过将 `*ok ` 设置为 `false` 来报告失败,通过将 `*ok ` 设置为 `true` 来报告成功。
字符串转换始终在“C”区域设置下进行。若需进行依赖区域设置的转换,请使用QLocale::toDouble()
出于历史原因,此函数不处理千位分隔符。若需转换此类数字,请使用QLocale::toDouble()。
另请参阅 QString::toDouble()。
float QStringRef::toFloat(bool *ok = nullptr) const
返回已转换为float 值的字符串。
如果转换发生溢出,则返回无穷大;如果因其他原因(例如下溢)导致转换失败,则返回 0.0。
如果 `ok ` 不是 `nullptr`,则通过将 *ok 设置为 `false` 来报告失败,通过将 *ok 设置为 `true` 来报告成功。
字符串转换始终在“C”区域设置下进行。若需进行与区域设置相关的转换,请使用QLocale::toFloat()
另请参阅 QString::toFloat()。
int QStringRef::toInt(bool *ok = nullptr, int base = 10) const
返回将字符串转换为int 的字符串,转换时使用基数base (默认值为10,必须在2到36之间,或为0)。如果转换失败,则返回0。
如果 `ok ` 不是 `nullptr`,则通过将 `*ok ` 设置为 `false` 来报告失败,通过将 `*ok ` 设置为 `true` 来报告成功。
如果base 为 0,则采用 C 语言约定:如果字符串以 "0x" 开头,则使用 16 进制;如果字符串以 "0" 开头,则使用 8 进制;否则,使用 10 进制。
字符串转换始终在“C”区域设置下进行。如需进行与区域设置相关的转换,请使用QLocale::toInt()
另请参阅 QString::toInt()。
QByteArray QStringRef::toLatin1() const
返回字符串的Latin-1表示形式,格式为QByteArray 。
如果字符串包含非Latin-1字符,则返回的字节数组未定义。这些字符可能会被省略或替换为问号。
另请参阅 toUtf8()、toLocal8Bit() 和QStringEncoder 。
QByteArray QStringRef::toLocal8Bit() const
返回字符串在本地 8 位编码下的表示形式,格式为 `QByteArray`。如果字符串包含本地 8 位编码不支持的字符,则返回的字节数组未定义。
在 Unix 系统上,这等同于 `toUtf8()`;在 Windows 系统上,则使用系统当前的代码页。
如果该字符串包含任何无法在该区域设置中编码的字符,则返回的字节数组未定义。这些字符可能会被忽略或替换为其他字符。
另请参阅 toLatin1()、toUtf8() 以及QStringEncoder 。
long QStringRef::toLong(bool *ok = nullptr, int base = 10) const
返回将字符串转换为long 格式的结果,转换时使用基数base (默认值为10,必须在2到36之间,或为0)。如果转换失败,则返回0。
如果ok 不是nullptr ,则通过将 *ok 设置为false 来报告失败,通过将 *ok 设置为true 来报告成功。
如果base 为 0,则采用 C 语言约定:如果字符串以 "0x" 开头,则采用 16 进制;如果字符串以 "0" 开头,则采用 8 进制;否则,采用 10 进制。
字符串转换始终在“C”区域设置下进行。若需进行依赖区域设置的转换,请使用QLocale::toLong()
另请参阅 QString::toLong()。
qlonglong QStringRef::toLongLong(bool *ok = nullptr, int base = 10) const
返回将字符串转换为long long 格式的结果,转换时使用基数base (默认值为10,必须在2到36之间,或为0)。如果转换失败,则返回0。
如果 `ok ` 不是 `nullptr`,则通过将 `*ok ` 设置为 `false` 来报告失败,通过将 `*ok ` 设置为 `true` 来报告成功。
如果base 为 0,则采用 C 语言约定:如果字符串以 "0x" 开头,则使用 16 进制;如果字符串以 "0" 开头,则使用 8 进制;否则,使用 10 进制。
字符串转换始终在“C”区域设置下进行。如需进行与区域设置相关的转换,请使用QLocale::toLongLong()
另请参阅 QString::toLongLong()。
short QStringRef::toShort(bool *ok = nullptr, int base = 10) const
返回将字符串转换为short 格式的结果,转换时使用基数base (默认值为10,必须在2到36之间,或为0)。如果转换失败,则返回0。
如果 `ok ` 不是 `nullptr`,则通过将 `*ok ` 设置为 `false` 来报告失败,通过将 `*ok ` 设置为 `true` 来报告成功。
如果base 为 0,则采用 C 语言约定:如果字符串以 "0x" 开头,则使用 16 进制;如果字符串以 "0" 开头,则使用 8 进制;否则,使用 10 进制。
字符串转换始终在“C”区域设置下进行。若需进行与区域设置相关的转换,请使用QLocale::toShort()
另请参阅 QString::toShort()。
QString QStringRef::toString() const
返回字符串引用的一份副本,该副本为QString 对象。
如果字符串引用并非该字符串的完整引用(即position() 结果为 0,且size() 等于string()->size()),则本函数将分配一个新的字符串并返回。
另请参阅 string()。
uint QStringRef::toUInt(bool *ok = nullptr, int base = 10) const
返回将字符串转换为unsigned int 格式的结果,转换时使用基数base (默认值为10,必须在2到36之间,或为0)。如果转换失败,则返回0。
如果 `ok ` 不是 `nullptr`,则通过将 `*ok ` 设置为 `false` 来报告失败,通过将 `*ok ` 设置为 `true` 来报告成功。
如果base 为 0,则采用 C 语言约定:如果字符串以 "0x" 开头,则使用 16 进制;如果字符串以 "0" 开头,则使用 8 进制;否则,使用 10 进制。
字符串转换始终在“C”区域设置下进行。若需进行与区域设置相关的转换,请使用QLocale::toUInt()
另请参阅 QString::toUInt()。
ulong QStringRef::toULong(bool *ok = nullptr, int base = 10) const
返回将字符串转换为unsigned long 格式的结果,转换时采用基数base (默认值为10,必须在2到36之间,或为0)。如果转换失败,则返回0。
如果 `ok ` 不是 `nullptr`,则通过将 `*ok ` 设置为 `false` 来报告失败,通过将 `*ok ` 设置为 `true` 来报告成功。
如果base 为 0,则采用 C 语言约定:如果字符串以 "0x" 开头,则使用 16 进制;如果字符串以 "0" 开头,则使用 8 进制;否则,使用 10 进制。
字符串转换始终在“C”区域设置下进行。若需进行与区域设置相关的转换,请使用QLocale::toULongLong()
另请参阅 QString::toULong()。
qulonglong QStringRef::toULongLong(bool *ok = nullptr, int base = 10) const
返回将字符串转换为unsigned long long 格式的结果,转换时使用基数base (默认值为10,必须在2到36之间,或为0)。如果转换失败,则返回0。
如果 `ok ` 不是 `nullptr`,则通过将 `*ok ` 设置为 `false` 来报告失败,通过将 `*ok ` 设置为 `true` 来报告成功。
如果base 为 0,则采用 C 语言约定:如果字符串以 "0x" 开头,则使用 16 进制;如果字符串以 "0" 开头,则使用 8 进制;否则,使用 10 进制。
字符串转换始终在“C”区域设置下进行。若需进行与区域设置相关的转换,请使用QLocale::toULongLong()
另请参阅 QString::toULongLong()。
ushort QStringRef::toUShort(bool *ok = nullptr, int base = 10) const
返回将字符串转换为unsigned short 格式的结果,转换时采用基数base (默认值为10,必须在2到36之间,或为0)。如果转换失败,则返回0。
如果 `ok ` 不是 `nullptr`,则通过将 `*ok ` 设置为 `false` 来报告失败,通过将 `*ok ` 设置为 `true` 来报告成功。
如果base 为 0,则采用 C 语言约定:如果字符串以 "0x" 开头,则使用 16 进制;如果字符串以 "0" 开头,则使用 8 进制;否则,使用 10 进制。
字符串转换始终在“C”区域设置下进行。如需进行与区域设置相关的转换,请使用QLocale::toUShort()
另请参阅 QString::toUShort()。
QList<uint> QStringRef::toUcs4() const
返回该字符串的UCS-4/UTF-32表示形式,类型为QList<uint>。
UCS-4 是一种 Unicode 编码方案,因此它是无损的。该字符串中的所有字符都将以 UCS-4 进行编码。该字符串中任何无效的码单元序列都将被替换为 Unicode 的替换字符(QChar::ReplacementCharacter ,对应于U+FFFD )。
返回的列表末尾不以\0 结尾。
另请参阅 toUtf8()、toLatin1()、toLocal8Bit() 以及QStringEncoder 。
QByteArray QStringRef::toUtf8() const
返回该字符串的 UTF-8 表示形式,即一个QByteArray 对象。
UTF-8 是一种 Unicode 编码方案,能够表示 Unicode 字符串中的所有字符,例如QString 。
另请参阅 toLatin1()、toLocal8Bit() 和QStringEncoder 。
QStringRef QStringRef::trimmed() const
返回一个已去除首尾空白字符的字符串。
空格指任何由 `QChar::isSpace()` 返回 `true` 的字符。这包括 ASCII 字符 '\t'、'\n'、'\v'、'\f'、'\r' 以及 ' '。
与 `QString::simplified()` 不同,`trimmed()` 不会处理内部的空格。
如果在移除空格后,新的position() 无法用int 表示,则行为未定义。
另请参阅 QString::trimmed()。
[noexcept] void QStringRef::truncate(int position)
在指定的position 索引处截断字符串。
如果指定的position 索引超出了字符串的末尾,则不会发生任何操作。
如果position 为负数,则等同于传入零。
另请参阅 QString::truncate()。
const QChar *QStringRef::unicode() const
返回字符串引用对应的 Unicode 表示形式。由于数据直接来源于被引用的字符串,因此除非该字符串引用包含字符串的空终止符,否则它不会以\0'结尾。
另请参阅 string()。
[noexcept] bool QStringRef::operator!=(const char *s) const
s 常量字符指针会通过fromUtf8()函数转换为QStringRef 。
您可以在编译应用程序时定义 `QT_NO_CAST_FROM_ASCII ` 来禁用此运算符。例如,如果您希望确保所有用户可见的字符串都经过 `QObject::tr()` 处理,此方法便十分有用。
如果该字符串与参数字符串s 在词法上不相同,则返回true ;否则返回false 。
此函数重载了 QStringRef::operator!=()。
另请参阅 QT_NO_CAST_FROM_ASCII 。
[noexcept] bool QStringRef::operator<(const char *s) const
s 类型的 const char 指针会通过 fromUtf8() 函数转换为QStringRef 类型。
您可以在编译应用程序时通过定义 `QT_NO_CAST_FROM_ASCII ` 来禁用此运算符。例如,如果您希望确保所有用户可见的字符串都经过 `QObject::tr()` 处理,这将非常有用。
如果该字符串在词法上小于参数字符串s ,则返回true ;否则返回false 。
此函数重载了QStringRef::operator<()。
另请参见 QT_NO_CAST_FROM_ASCII 。
[noexcept] bool QStringRef::operator<=(const char *s) const
s 常量字符指针会通过fromUtf8()函数转换为QStringRef 。
您可以在编译应用程序时通过定义 `QT_NO_CAST_FROM_ASCII ` 来禁用此运算符。例如,如果您希望确保所有用户可见的字符串都通过 `QObject::tr()` 处理,此方法将非常有用。
如果该字符串在词法上小于或等于参数字符串 `s`,则返回 `true `;否则返回 `false`。
此函数重载了 `QStringRef::operator<=()`。
另请参见 QT_NO_CAST_FROM_ASCII 。
QStringRef &QStringRef::operator=(const QString *string)
构建指向给定string 的字符串引用,并将该引用赋值给此字符串引用,同时返回结果。
警告: QStringRef 使用int (32 位)来表示其size()。在 Qt 6 中,QString 的大小表示为qsizetype ,对于 64 位构建而言,其长度为 64 位。请确保输入的大小能容纳在 32 位内,否则会发生the behavior is undefined 。
[implicit] QStringRef &QStringRef::operator=(const QStringRef &other)
将字符串引用 `other ` 赋值给此字符串引用,并返回结果。
[noexcept] bool QStringRef::operator==(const char *s) const
s 字节数组会通过fromUtf8()函数转换为QStringRef 。该函数会在遇到第一个NUL字符或到达字节数组末尾时停止转换。
您可以在编译应用程序时通过定义 `QT_NO_CAST_FROM_ASCII ` 来禁用此运算符。例如,如果您希望确保所有用户可见的字符串都经过 `QObject::tr()` 处理,此方法会非常有用。
如果该字符串与参数字符串s 在词法上相等,则返回true ;否则返回false 。
此函数重载了QStringRef::operator==()。
另请参阅 QT_NO_CAST_FROM_ASCII 。
[noexcept] bool QStringRef::operator>(const char *s) const
s 常量字符指针会通过fromUtf8()函数转换为QStringRef 。
您可以在编译应用程序时通过定义 `QT_NO_CAST_FROM_ASCII ` 来禁用此运算符。例如,如果您希望确保所有用户可见的字符串都经过 `QObject::tr()` 处理,这会非常有用。
如果该字符串在词法上大于参数字符串s ,则返回true ;否则返回false 。
此函数重载了QStringRef::operator>()。
另请参阅 QT_NO_CAST_FROM_ASCII 。
[noexcept] bool QStringRef::operator>=(const char *s) const
s 类型的 const char 指针会通过 fromUtf8() 函数转换为QStringRef 类型。
您可以在编译应用程序时定义 `QT_NO_CAST_FROM_ASCII ` 来禁用此运算符。例如,如果您希望确保所有用户可见的字符串都经过 `QObject::tr()` 处理,此方法便十分有用。
如果该字符串在字面量上大于或等于参数字符串s ,则返回true 。否则返回false 。
此函数重载了QStringRef::operator>=()。
另请参阅 QT_NO_CAST_FROM_ASCII 。
QChar QStringRef::operator[](int position) const
返回字符串引用中位于给定索引position 处的字符。
position 必须是字符串引用中的有效索引位置(即 0 <=position <size())。
另请参阅 at()。
相关非成员
[noexcept] bool operator<(const QStringRef &s1, const QStringRef &s2)
如果字符串引用s1 在词法上小于字符串引用s2 ,则返回true ;否则返回false 。
另请参阅 Comparing Strings 。
[noexcept] bool operator<=(const QStringRef &s1, const QStringRef &s2)
如果字符串引用s1 在词法上小于或等于字符串引用s2 ,则返回true ;否则返回false 。
另请参阅 Comparing Strings 。
[noexcept] bool operator==(QLatin1String s1, const QStringRef &s2)
如果字符串s1 与字符串引用s2 在词法上相等,则返回 `true `;否则返回 `false`。
[noexcept] bool operator==(const QString &s1, const QStringRef &s2)
如果字符串s1 与字符串引用s2 在词法上相等,则返回true ;否则返回false 。
[noexcept] bool operator==(const QStringRef &s1, const QStringRef &s2)
如果字符串引用 `s1 ` 与字符串引用 `s2` 在词法上相等,则返回 `true `;否则返回 `false`。
[noexcept] bool operator>(const QStringRef &s1, const QStringRef &s2)
如果字符串引用s1 在词法上大于字符串引用s2 ,则返回true ;否则返回false 。
另请参阅 Comparing Strings 。
[noexcept] bool operator>=(const QStringRef &s1, const QStringRef &s2)
如果字符串引用s1 的词法大小大于或等于字符串引用s2 ,则返回true ;否则返回false 。
另请参阅 Comparing Strings 。
© 2026 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.