QLatin1String 类提供围绕 US-ASCII/Latin-1 编码字符串文字的瘦包裹器。 更多...
头: | #include <QLatin1String> |
CMake: |
find_package(Qt6 COMPONENTS Core REQUIRED)
target_link_libraries(mytarget PRIVATE Qt6::Core) |
qmake: | QT += core |
注意: 此类的所有函数 可重入 .
const_iterator | |
const_reference | |
const_reverse_iterator | |
difference_type | |
iterator | |
reference | |
reverse_iterator | |
size_type | |
value_type |
QLatin1String (const QByteArray & str ) | |
QLatin1String (const char * str , qsizetype size ) | |
QLatin1String (const char * first , const char * last ) | |
QLatin1String (const char * str ) | |
QLatin1String () | |
QString | arg (Args &&... args ) const |
QLatin1Char | at (qsizetype pos ) const |
QLatin1Char | back () const |
QLatin1String::const_iterator | begin () const |
QLatin1String::const_iterator | cbegin () const |
QLatin1String::const_iterator | cend () const |
void | chop (qsizetype length ) |
QLatin1String | chopped (qsizetype length ) const |
int | compare (QStringView str , Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
int | compare (QLatin1String l1 , Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
int | compare (QChar ch ) const |
int | compare (QChar ch , Qt::CaseSensitivity cs ) const |
bool | contains (QStringView str , Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
bool | contains (QLatin1String l1 , Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
bool | contains (QChar c , Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
QLatin1String::const_reverse_iterator | crbegin () const |
QLatin1String::const_reverse_iterator | crend () const |
const char * | data () const |
QLatin1String::const_iterator | end () const |
bool | endsWith (QStringView str , Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
bool | endsWith (QLatin1String l1 , Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
bool | endsWith (QChar ch ) const |
bool | endsWith (QChar ch , Qt::CaseSensitivity cs ) const |
QLatin1String | first (qsizetype n ) const |
QLatin1Char | front () const |
qsizetype | indexOf (QStringView str , qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
qsizetype | indexOf (QLatin1String l1 , qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
qsizetype | indexOf (QChar c , qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
bool | isEmpty () const |
bool | isNull () const |
QLatin1String | last (qsizetype n ) const |
qsizetype | lastIndexOf (QStringView str , qsizetype from , Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
qsizetype | lastIndexOf (QStringView str , Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
qsizetype | lastIndexOf (QLatin1String l1 , Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
qsizetype | lastIndexOf (QLatin1String l1 , qsizetype from , Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
qsizetype | lastIndexOf (QChar c , qsizetype from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
const char * | latin1 () const |
QLatin1String | left (qsizetype length ) const |
QLatin1String | mid (qsizetype start , qsizetype length = -1) const |
QLatin1String::const_reverse_iterator | rbegin () const |
QLatin1String::const_reverse_iterator | rend () const |
QLatin1String | right (qsizetype length ) const |
qsizetype | size () const |
QLatin1String | sliced (qsizetype pos ) const |
QLatin1String | sliced (qsizetype pos , qsizetype n ) const |
bool | startsWith (QStringView str , Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
bool | startsWith (QLatin1String l1 , Qt::CaseSensitivity cs = Qt::CaseSensitive) const |
bool | startsWith (QChar ch ) const |
bool | startsWith (QChar ch , Qt::CaseSensitivity cs ) const |
QString | toString () const |
decltype(qTokenize(*this, std::forward<Needle>(needle), flags...)) | tokenize (Needle && sep , Flags... flags ) const |
QLatin1String | trimmed () const |
void | truncate (qsizetype length ) |
bool | operator!= (const char * other ) const |
bool | operator!= (const QByteArray & other ) const |
bool | operator< (const char * other ) const |
bool | operator< (const QByteArray & other ) const |
bool | operator<= (const char * other ) const |
bool | operator<= (const QByteArray & other ) const |
bool | operator== (const char * other ) const |
bool | operator== (const QByteArray & other ) const |
bool | operator> (const char * other ) const |
bool | operator> (const QByteArray & other ) const |
bool | operator>= (const char * other ) const |
bool | operator>= (const QByteArray & other ) const |
QLatin1Char | operator[] (qsizetype pos ) const |
bool | operator!= (QLatin1String s1 , QLatin1String s2 ) |
bool | operator!= (QChar ch , QLatin1String s ) |
bool | operator!= (QLatin1String s , QChar ch ) |
bool | operator!= (QStringView s1 , QLatin1String s2 ) |
bool | operator!= (QLatin1String s1 , QStringView s2 ) |
bool | operator!= (const char * s1 , QLatin1String s2 ) |
bool | operator< (QLatin1String s1 , QLatin1String s2 ) |
bool | operator< (QChar ch , QLatin1String s ) |
bool | operator< (QLatin1String s , QChar ch ) |
bool | operator< (QStringView s1 , QLatin1String s2 ) |
bool | operator< (QLatin1String s1 , QStringView s2 ) |
bool | operator< (const char * s1 , QLatin1String s2 ) |
bool | operator<= (QLatin1String s1 , QLatin1String s2 ) |
bool | operator<= (QChar ch , QLatin1String s ) |
bool | operator<= (QLatin1String s , QChar ch ) |
bool | operator<= (QStringView s1 , QLatin1String s2 ) |
bool | operator<= (QLatin1String s1 , QStringView s2 ) |
bool | operator<= (const char * s1 , QLatin1String s2 ) |
bool | operator== (QLatin1String s1 , QLatin1String s2 ) |
bool | operator== (QChar ch , QLatin1String s ) |
bool | operator== (QLatin1String s , QChar ch ) |
bool | operator== (QStringView s1 , QLatin1String s2 ) |
bool | operator== (QLatin1String s1 , QStringView s2 ) |
bool | operator== (const char * s1 , QLatin1String s2 ) |
bool | operator> (QLatin1String s1 , QLatin1String s2 ) |
bool | operator> (QChar ch , QLatin1String s ) |
bool | operator> (QLatin1String s , QChar ch ) |
bool | operator> (QStringView s1 , QLatin1String s2 ) |
bool | operator> (QLatin1String s1 , QStringView s2 ) |
bool | operator> (const char * s1 , QLatin1String s2 ) |
bool | operator>= (QLatin1String s1 , QLatin1String s2 ) |
bool | operator>= (QChar ch , QLatin1String s ) |
bool | operator>= (QLatin1String s , QChar ch ) |
bool | operator>= (QStringView s1 , QLatin1String s2 ) |
bool | operator>= (QLatin1String s1 , QStringView s2 ) |
bool | operator>= (const char * s1 , QLatin1String s2 ) |
很多
QString
's member functions are overloaded to accept
const char *
而不是
QString
. This includes the copy constructor, the assignment operator, the comparison operators, and various other functions such as
insert()
,
replace()
,和
indexOf()
. These functions are usually optimized to avoid constructing a
QString
对象为
const char *
data. For example, assuming
str
是
QString
,
if (str == "auto" || str == "extern" || str == "static" || str == "register") { ... }
is much faster than
if (str == QString("auto") || str == QString("extern") || str == QString("static") || str == QString("register")) { ... }
because it doesn't construct four temporary QString objects and make a deep copy of the character data.
Applications that define
QT_NO_CAST_FROM_ASCII
(as explained in the
QString
documentation) don't have access to
QString
's
const char *
API. To provide an efficient way of specifying constant Latin-1 strings, Qt provides the QLatin1String, which is just a very thin wrapper around a
const char *
. Using QLatin1String, the example code above becomes
if (str == QLatin1String("auto") || str == QLatin1String("extern") || str == QLatin1String("static") || str == QLatin1String("register") { ... }
This is a bit longer to type, but it provides exactly the same benefits as the first version of the code, and is faster than converting the Latin-1 strings using QString::fromLatin1 ().
Thanks to the QString (QLatin1String) constructor, QLatin1String can be used everywhere a QString is expected. For example:
QLabel *label = new QLabel(QLatin1String("MOD"), this);
注意: If the function you're calling with a QLatin1String argument isn't actually overloaded to take QLatin1String, the implicit conversion to QString will trigger a memory allocation, which is usually what you want to avoid by using QLatin1String in the first place. In those cases, using QStringLiteral may be the better option.
另请参阅 QString , QLatin1Char , QStringLiteral ,和 QT_NO_CAST_FROM_ASCII .
[alias, since 5.10]
QLatin1String::
const_iterator
该 typedef 在 Qt 5.10 引入。
另请参阅 iterator and const_reverse_iterator .
[alias, since 5.11]
QLatin1String::
const_reference
别名化的
reference
。为兼容 STL (标准模板库) 提供。
该 typedef 在 Qt 5.11 引入。
[alias, since 5.10]
QLatin1String::
const_reverse_iterator
该 typedef 在 Qt 5.10 引入。
另请参阅 reverse_iterator and const_iterator .
[alias, since 5.10]
QLatin1String::
difference_type
别名化的
qsizetype
。为兼容 STL (标准模板库) 提供。
该 typedef 在 Qt 5.10 引入。
[alias, since 5.10]
QLatin1String::
iterator
QLatin1String does not support mutable iterators, so this is the same as const_iterator.
该 typedef 在 Qt 5.10 引入。
另请参阅 const_iterator and reverse_iterator .
[alias, since 5.10]
QLatin1String::
reference
别名化的
value_type &
。为兼容 STL (标准模板库) 提供。
该 typedef 在 Qt 5.10 引入。
[alias, since 5.10]
QLatin1String::
reverse_iterator
QLatin1String does not support mutable reverse iterators, so this is the same as const_reverse_iterator.
该 typedef 在 Qt 5.10 引入。
另请参阅 const_reverse_iterator and iterator .
[alias, since 5.10]
QLatin1String::
size_type
别名化的
qsizetype
。为兼容 STL (标准模板库) 提供。
注意:
In version prior to Qt 6, this was an alias for
int
, restricting the amount of data that could be held in a
QLatin1String
on 64-bit architectures.
该 typedef 在 Qt 5.10 引入。
[alias, since 5.10]
QLatin1String::
value_type
别名化的
const char
。为兼容 STL (标准模板库) 提供。
该 typedef 在 Qt 5.10 引入。
[since 6.0]
template <typename Needle, typename Flags>
decltype
(
qTokenize
(*
this
,
std::forward
<
Needle
>(
needle
),
flags
...)) QLatin1String::
tokenize
(
Needle
&&
sep
,
Flags
...
flags
) const
Splits the string into substring views wherever sep occurs, and returns a lazy sequence of those strings.
相当于
return QStringTokenizer{std::forward<Needle>(sep), flags...};
except it works without C++17 Class Template Argument Deduction (CTAD) enabled in the compiler.
见 QStringTokenizer for how sep and flags interact to form the result.
注意: While this function returns QStringTokenizer , you should never, ever, name its template arguments explicitly. If you can use C++17 Class Template Argument Deduction (CTAD), you may write
QStringTokenizer result = sv.tokenize(sep);
(without template arguments). If you can't use C++17 CTAD, you must store the return value only in
auto
变量:
auto result = sv.tokenize(sep);
This is because the template arguments of QStringTokenizer have a very subtle dependency on the specific tokenize () overload from which they are returned, and they don't usually correspond to the type used for the separator.
该函数在 Qt 6.0 引入。
另请参阅 QStringTokenizer and qTokenize ().
[since 5.14]
template <typename Args>
QString
QLatin1String::
arg
(
Args
&&...
args
) const
Replaces occurrences of
%N
in this string with the corresponding argument from
args
. The arguments are not positional: the first of the
args
替换
%N
with the lowest
N
(all of them), the second of the
args
%N
with the next-lowest
N
etc.
Args
can consist of anything that implicitly converts to
QString
,
QStringView
or
QLatin1String
.
In addition, the following types are also supported: QChar , QLatin1Char .
该函数在 Qt 5.14 引入。
另请参阅 QString::arg ().
[since 6.2]
qsizetype
QLatin1String::
lastIndexOf
(
QLatin1String
l1
,
Qt::CaseSensitivity
cs
= Qt::CaseSensitive) const
[since 6.2]
qsizetype
QLatin1String::
lastIndexOf
(
QStringView
str
,
Qt::CaseSensitivity
cs
= Qt::CaseSensitive) const
此函数重载 lastIndexOf ().
Returns the index position of the last occurrence of the string-view str or Latin-1 string l1 , respectively, in this Latin-1 string. Returns -1 if str 找不到。
若 cs is Qt::CaseSensitive (default), the search is case sensitive; otherwise the search is case insensitive.
该函数在 Qt 6.2 引入。
[since 5.14]
qsizetype
QLatin1String::
lastIndexOf
(
QChar
c
,
qsizetype
from
= -1,
Qt::CaseSensitivity
cs
= Qt::CaseSensitive) const
[since 5.14]
qsizetype
QLatin1String::
lastIndexOf
(
QLatin1String
l1
,
qsizetype
from
,
Qt::CaseSensitivity
cs
= Qt::CaseSensitive) const
[since 5.14]
qsizetype
QLatin1String::
lastIndexOf
(
QStringView
str
,
qsizetype
from
,
Qt::CaseSensitivity
cs
= Qt::CaseSensitive) const
Returns the index position of the last occurrence of the string-view str , Latin-1 string l1 , or character ch , respectively, in this Latin-1 string, searching backward from index position from . Returns -1 if str 找不到。
若 from is -1, the search starts at the last character; if from is -2, at the next to last character and so on.
若 cs is Qt::CaseSensitive (default), the search is case sensitive; otherwise the search is case insensitive.
注意:
When searching for a 0-length
str
or
l1
, the match at the end of the data is excluded from the search by a negative
from
, even though
-1
is normally thought of as searching from the end of the string: the match at the end is
after
the last character, so it is excluded. To include such a final empty match, either give a positive value for
from
or omit the
from
parameter entirely.
该函数在 Qt 5.14 引入。
另请参阅 indexOf (), QStringView::lastIndexOf (), QStringView::indexOf (),和 QString::indexOf ().
[since 5.14]
bool
QLatin1String::
contains
(
QChar
c
,
Qt::CaseSensitivity
cs
= Qt::CaseSensitive) const
[since 5.14]
bool
QLatin1String::
contains
(
QLatin1String
l1
,
Qt::CaseSensitivity
cs
= Qt::CaseSensitive) const
[since 5.14]
bool
QLatin1String::
contains
(
QStringView
str
,
Qt::CaseSensitivity
cs
= Qt::CaseSensitive) const
返回
true
if this Latin-1 string contains an occurrence of the string-view
str
, Latin-1 string
l1
, or character
ch
;否则返回
false
.
若 cs is Qt::CaseSensitive (默认),搜索区分大小写;否则,搜索不区分大小写。
该函数在 Qt 5.14 引入。
另请参阅 indexOf (), QStringView::contains (), QStringView::indexOf (),和 QString::indexOf ().
[since 5.14]
qsizetype
QLatin1String::
indexOf
(
QChar
c
,
qsizetype
from
= 0,
Qt::CaseSensitivity
cs
= Qt::CaseSensitive) const
[since 5.14]
qsizetype
QLatin1String::
indexOf
(
QLatin1String
l1
,
qsizetype
from
= 0,
Qt::CaseSensitivity
cs
= Qt::CaseSensitive) const
[since 5.14]
qsizetype
QLatin1String::
indexOf
(
QStringView
str
,
qsizetype
from
= 0,
Qt::CaseSensitivity
cs
= Qt::CaseSensitive) const
Returns the index position of the first occurrence of the string-view str , Latin-1 string l1 , or character ch , respectively, in this Latin-1 string, searching forward from index position from . Returns -1 if str 找不到。
若 cs is Qt::CaseSensitive (default), the search is case sensitive; otherwise the search is case insensitive.
若 from is -1, the search starts at the last character; if it is -2, at the next to last character and so on.
该函数在 Qt 5.14 引入。
另请参阅 QString::indexOf ().
[since 5.10]
bool
QLatin1String::
endsWith
(
QChar
ch
) const
[since 5.10]
bool
QLatin1String::
endsWith
(
QChar
ch
,
Qt::CaseSensitivity
cs
) const
[since 5.10]
bool
QLatin1String::
endsWith
(
QLatin1String
l1
,
Qt::CaseSensitivity
cs
= Qt::CaseSensitive) const
[since 5.10]
bool
QLatin1String::
endsWith
(
QStringView
str
,
Qt::CaseSensitivity
cs
= Qt::CaseSensitive) const
返回
true
if this Latin-1 string ends with string-view
str
, Latin-1 string
l1
, or character
ch
, respectively; otherwise returns
false
.
若 cs is Qt::CaseSensitive (默认),搜索区分大小写;否则,搜索不区分大小写。
该函数在 Qt 5.10 引入。
另请参阅 startsWith ().
[since 5.10]
bool
QLatin1String::
startsWith
(
QChar
ch
) const
[since 5.10]
bool
QLatin1String::
startsWith
(
QChar
ch
,
Qt::CaseSensitivity
cs
) const
[since 5.10]
bool
QLatin1String::
startsWith
(
QLatin1String
l1
,
Qt::CaseSensitivity
cs
= Qt::CaseSensitive) const
[since 5.10]
bool
QLatin1String::
startsWith
(
QStringView
str
,
Qt::CaseSensitivity
cs
= Qt::CaseSensitive) const
返回
true
if this Latin-1 string starts with string-view
str
, Latin-1 string
l1
, or character
ch
, respectively; otherwise returns
false
.
若 cs is Qt::CaseSensitive (默认),搜索区分大小写;否则,搜索不区分大小写。
该函数在 Qt 5.10 引入。
另请参阅 endsWith ().
[since 5.14]
int
QLatin1String::
compare
(
QChar
ch
) const
[since 5.14]
int
QLatin1String::
compare
(
QChar
ch
,
Qt::CaseSensitivity
cs
) const
[since 5.14]
int
QLatin1String::
compare
(
QLatin1String
l1
,
Qt::CaseSensitivity
cs
= Qt::CaseSensitive) const
[since 5.14]
int
QLatin1String::
compare
(
QStringView
str
,
Qt::CaseSensitivity
cs
= Qt::CaseSensitive) const
Returns an integer that compares to zero as this Latin-1 string compares to the string-view str , Latin-1 string l1 , or character ch ,分别。
若 cs is Qt::CaseSensitive (the default), the comparison is case sensitive; otherwise the comparison is case-insensitive.
该函数在 Qt 5.14 引入。
另请参阅 operator== (), operator< (),和 operator> ().
Constructs a QLatin1String object that stores str .
The string data is not copied. The caller must be able to guarantee that str will not be deleted or modified as long as the QLatin1String object exists.
另请参阅 latin1 ().
Constructs a QLatin1String object that stores str with size .
The string data is not copied. The caller must be able to guarantee that str will not be deleted or modified as long as the QLatin1String object exists.
另请参阅 latin1 ().
[since 5.10]
QLatin1String::
QLatin1String
(const
char
*
first
, const
char
*
last
)
Constructs a QLatin1String object that stores first 按长度 ( last - first ).
范围
[first,last)
must remain valid for the lifetime of this Latin-1 string object.
传递
nullptr
as
first
是安全的若
last
is
nullptr
, too, and results in a null Latin-1 string.
行为未定义若
last
precedes
first
,
first
is
nullptr
and
last
is not, or if
last - first > INT_MAX
.
该函数在 Qt 5.10 引入。
Constructs a QLatin1String object that stores str .
The string data is not copied. The caller must be able to guarantee that str will not be deleted or modified as long as the QLatin1String object exists.
另请参阅 latin1 ().
[since 5.6]
QLatin1String::
QLatin1String
()
Constructs a QLatin1String object that stores a nullptr.
该函数在 Qt 5.6 引入。
[since 5.8]
QLatin1Char
QLatin1String::
at
(
qsizetype
pos
) const
返回字符位于位置 pos 在此对象。
注意: This function performs no error checking. The behavior is undefined when pos < 0 or pos >= size ().
该函数在 Qt 5.8 引入。
另请参阅 operator[] ().
[since 5.10]
QLatin1Char
QLatin1String::
back
() const
返回字符串中的最后一个字符。如同
at(size() - 1)
.
此函数为兼容 STL (标准模板库) 提供。
警告: 在空字符串调用此函数,将构成未定义行为。
该函数在 Qt 5.10 引入。
另请参阅 front (), at (),和 operator[] ().
[since 5.10]
QLatin1String::const_iterator
QLatin1String::
begin
() const
返回常量 STL 样式迭代器 指向字符串中的首个字符。
此函数为兼容 STL (标准模板库) 提供。
该函数在 Qt 5.10 引入。
另请参阅 end (), cbegin (), rbegin (),和 data ().
[since 5.10]
QLatin1String::const_iterator
QLatin1String::
cbegin
() const
如同 begin ().
此函数为兼容 STL (标准模板库) 提供。
该函数在 Qt 5.10 引入。
另请参阅 cend (), begin (), crbegin (),和 data ().
[since 5.10]
QLatin1String::const_iterator
QLatin1String::
cend
() const
如同 end ().
此函数为兼容 STL (标准模板库) 提供。
该函数在 Qt 5.10 引入。
另请参阅 cbegin (), end (),和 crend ().
[since 5.10]
void
QLatin1String::
chop
(
qsizetype
length
)
Truncates this string by length 字符。
如同
*this = left(size() - length)
.
注意: 行为未定义当 length < 0 or length > size ().
该函数在 Qt 5.10 引入。
另请参阅 sliced (), first (), last (), chopped (),和 truncate ().
[since 5.10]
QLatin1String
QLatin1String::
chopped
(
qsizetype
length
) const
返回子字符串长度 size () - length 起始于此对象的开头。
如同
left(size() - length)
.
注意: 行为未定义当 length < 0 or length > size ().
该函数在 Qt 5.10 引入。
另请参阅 sliced (), first (), last (), chop (),和 truncate ().
[since 5.10]
QLatin1String::const_reverse_iterator
QLatin1String::
crbegin
() const
如同 rbegin ().
此函数为兼容 STL (标准模板库) 提供。
该函数在 Qt 5.10 引入。
另请参阅 crend (), rbegin (),和 cbegin ().
[since 5.10]
QLatin1String::const_reverse_iterator
QLatin1String::
crend
() const
如同 rend ().
此函数为兼容 STL (标准模板库) 提供。
该函数在 Qt 5.10 引入。
另请参阅 crbegin (), rend (),和 cend ().
Returns the Latin-1 string stored in this object.
[since 5.10]
QLatin1String::const_iterator
QLatin1String::
end
() const
返回常量 STL 样式迭代器 仅仅指向字符串中最后一个字符的后面。
此函数为兼容 STL (标准模板库) 提供。
该函数在 Qt 5.10 引入。
另请参阅 begin (), cend (),和 rend ().
[since 6.0]
QLatin1String
QLatin1String::
first
(
qsizetype
n
) const
Returns a Latin-1 string that contains the first n characters of this Latin-1 string.
注意: 行为未定义当 n < 0 or n > size ().
该函数在 Qt 6.0 引入。
另请参阅 last (), startsWith (), chopped (), chop (),和 truncate ().
[since 5.10]
QLatin1Char
QLatin1String::
front
() const
Returns the first character in the string. Same as
at(0)
.
此函数为兼容 STL (标准模板库) 提供。
警告: 在空字符串调用此函数,将构成未定义行为。
该函数在 Qt 5.10 引入。
另请参阅 back (), at (),和 operator[] ().
[since 5.10]
bool
QLatin1String::
isEmpty
() const
Returns whether the Latin-1 string stored in this object is empty (
size() == 0
) or not.
该函数在 Qt 5.10 引入。
[since 5.10]
bool
QLatin1String::
isNull
() const
Returns whether the Latin-1 string stored in this object is null (
data() == nullptr
) or not.
该函数在 Qt 5.10 引入。
[since 6.0]
QLatin1String
QLatin1String::
last
(
qsizetype
n
) const
Returns a Latin-1 string that contains the last n characters of this Latin-1 string.
注意: 行为未定义当 n < 0 or n > size ().
该函数在 Qt 6.0 引入。
另请参阅 first (), endsWith (), chopped (), chop (),和 truncate ().
Returns the Latin-1 string stored in this object.
[since 5.8]
QLatin1String
QLatin1String::
left
(
qsizetype
length
) const
若知道 length 不可以超出边界,使用 first () 代替在新代码中,因为它更快。
返回子字符串长度 length starting at position 0 in this Latin-1 string.
The entire Latin-1 string is returned if length >= size (),或小于 0。
该函数在 Qt 5.8 引入。
另请参阅 first (), last (), sliced (), startsWith (), chopped (), chop (),和 truncate ().
[since 5.8]
QLatin1String
QLatin1String::
mid
(
qsizetype
start
,
qsizetype
length
= -1) const
返回子字符串长度 length 起始于位置 start in this Latin-1 string.
若知道 start and length 不可以超出边界,使用 sliced () 代替在新代码中,因为它更快。
Returns an empty Latin-1 string if start exceeds the length of this Latin-1 string. If there are less than length characters available in this Latin-1 string starting at start ,或者若 length is negative (default), the function returns all characters that are available from start .
该函数在 Qt 5.8 引入。
另请参阅 first (), last (), sliced (), chopped (), chop (),和 truncate ().
[since 5.10]
QLatin1String::const_reverse_iterator
QLatin1String::
rbegin
() const
返回常量 STL-style reverse iterator pointing to the first character in the string, in reverse order.
此函数为兼容 STL (标准模板库) 提供。
该函数在 Qt 5.10 引入。
另请参阅 rend (), crbegin (),和 begin ().
[since 5.10]
QLatin1String::const_reverse_iterator
QLatin1String::
rend
() const
返回 STL-style reverse iterator pointing just after the last character in the string, in reverse order.
此函数为兼容 STL (标准模板库) 提供。
该函数在 Qt 5.10 引入。
另请参阅 rbegin (), crend (),和 end ().
[since 5.8]
QLatin1String
QLatin1String::
right
(
qsizetype
length
) const
若知道 length 不可以超出边界,使用 last () 代替在新代码中,因为它更快。
返回子字符串长度 length 起始于位置 size () - length in this Latin-1 string.
The entire Latin-1 string is returned if length >= size (),或小于 0。
该函数在 Qt 5.8 引入。
另请参阅 first (), last (), sliced (), endsWith (), chopped (), chop (),和 truncate ().
Returns the size of the Latin-1 string stored in this object.
注意:
In version prior to Qt 6, this function returned
int
, restricting the amount of data that could be held in a
QLatin1String
on 64-bit architectures.
[since 6.0]
QLatin1String
QLatin1String::
sliced
(
qsizetype
pos
) const
Returns a Latin-1 string starting at position pos in this Latin-1 string, and extending to its end.
注意: 行为未定义当 pos < 0 or pos > size ().
该函数在 Qt 6.0 引入。
另请参阅 first (), last (), chopped (), chop (),和 truncate ().
[since 6.0]
QLatin1String
QLatin1String::
sliced
(
qsizetype
pos
,
qsizetype
n
) const
Returns a Latin-1 string that points to n characters of this Latin-1 string, starting at position pos .
注意:
行为未定义当
pos
< 0,
n
< 0, or
pos + n > size()
.
该函数在 Qt 6.0 引入。
另请参阅 first (), last (), chopped (), chop (),和 truncate ().
[since 6.0]
QString
QLatin1String::
toString
() const
Converts this Latin-1 string into a QString . Equivalent to
return QString(*this);
该函数在 Qt 6.0 引入。
[since 5.10]
QLatin1String
QLatin1String::
trimmed
() const
Strips leading and trailing whitespace and returns the result.
空白意味着任何字符其。
QChar::isSpace
() 返回
true
。这包括 ASCII 字符 \t、\n、\v、\f、\r、及 " "。
该函数在 Qt 5.10 引入。
[since 5.10]
void
QLatin1String::
truncate
(
qsizetype
length
)
Truncates this string to length length .
如同
*this = left(length)
.
注意: 行为未定义当 length < 0 or length > size ().
该函数在 Qt 5.10 引入。
另请参阅 sliced (), first (), last (), chopped (),和 chop ().
返回
true
if this string is not equal to const char pointer
other
;否则返回
false
.
other const char pointer is converted to a QString 使用 QString::fromUtf8 () 函数。
可以禁用此运算符通过定义 QT_NO_CAST_FROM_ASCII when you compile your applications. This can be useful if you want to ensure that all user-visible strings go through QObject::tr (), for example.
另请参阅 Comparing Strings .
[since 5.0]
bool
QLatin1String::
operator!=
(const
QByteArray
&
other
) const
This function overloads operator!=().
other byte array is converted to a QString 使用 QString::fromUtf8 () 函数。
可以禁用此运算符通过定义 QT_NO_CAST_FROM_ASCII when you compile your applications. This can be useful if you want to ensure that all user-visible strings go through QObject::tr (), for example.
该函数在 Qt 5.0 引入。
返回
true
if this string is lexically less than const char pointer
other
;否则返回
false
.
other const char pointer is converted to a QString 使用 QString::fromUtf8 () 函数。
可以禁用此运算符通过定义 QT_NO_CAST_FROM_ASCII when you compile your applications. This can be useful if you want to ensure that all user-visible strings go through QObject::tr (), for example.
另请参阅 Comparing Strings .
[since 5.0]
bool
QLatin1String::
operator<
(const
QByteArray
&
other
) const
这是重载函数。
other byte array is converted to a QString 使用 QString::fromUtf8 () 函数。
可以禁用此运算符通过定义 QT_NO_CAST_FROM_ASCII when you compile your applications. This can be useful if you want to ensure that all user-visible strings go through QObject::tr (), for example.
该函数在 Qt 5.0 引入。
返回
true
if this string is lexically less than or equal to const char pointer
other
;否则返回
false
.
other const char pointer is converted to a QString 使用 QString::fromUtf8 () 函数。
可以禁用此运算符通过定义 QT_NO_CAST_FROM_ASCII when you compile your applications. This can be useful if you want to ensure that all user-visible strings go through QObject::tr (), for example.
另请参阅 Comparing Strings .
[since 5.0]
bool
QLatin1String::
operator<=
(const
QByteArray
&
other
) const
这是重载函数。
other byte array is converted to a QString 使用 QString::fromUtf8 () 函数。
可以禁用此运算符通过定义 QT_NO_CAST_FROM_ASCII when you compile your applications. This can be useful if you want to ensure that all user-visible strings go through QObject::tr (), for example.
该函数在 Qt 5.0 引入。
返回
true
if the string is equal to const char pointer
other
;否则返回
false
.
other const char pointer is converted to a QString 使用 QString::fromUtf8 () 函数。
可以禁用此运算符通过定义 QT_NO_CAST_FROM_ASCII when you compile your applications. This can be useful if you want to ensure that all user-visible strings go through QObject::tr (), for example.
另请参阅 Comparing Strings .
[since 5.0]
bool
QLatin1String::
operator==
(const
QByteArray
&
other
) const
这是重载函数。
other byte array is converted to a QString 使用 QString::fromUtf8 () 函数。
可以禁用此运算符通过定义 QT_NO_CAST_FROM_ASCII when you compile your applications. This can be useful if you want to ensure that all user-visible strings go through QObject::tr (), for example.
该函数在 Qt 5.0 引入。
返回
true
if this string is lexically greater than const char pointer
other
;否则返回
false
.
other const char pointer is converted to a QString 使用 QString::fromUtf8 () 函数。
可以禁用此运算符通过定义 QT_NO_CAST_FROM_ASCII when you compile your applications. This can be useful if you want to ensure that all user-visible strings go through QObject::tr (), for example.
另请参阅 Comparing Strings .
[since 5.0]
bool
QLatin1String::
operator>
(const
QByteArray
&
other
) const
这是重载函数。
other byte array is converted to a QString 使用 QString::fromUtf8 () 函数。
可以禁用此运算符通过定义 QT_NO_CAST_FROM_ASCII when you compile your applications. This can be useful if you want to ensure that all user-visible strings go through QObject::tr (), for example.
该函数在 Qt 5.0 引入。
返回
true
if this string is lexically greater than or equal to const char pointer
other
;否则返回
false
.
other const char pointer is converted to a QString 使用 QString::fromUtf8 () 函数。
可以禁用此运算符通过定义 QT_NO_CAST_FROM_ASCII when you compile your applications. This can be useful if you want to ensure that all user-visible strings go through QObject::tr (), for example.
另请参阅 Comparing Strings .
[since 5.0]
bool
QLatin1String::
operator>=
(const
QByteArray
&
other
) const
这是重载函数。
other byte array is converted to a QString 使用 QString::fromUtf8 () 函数。
可以禁用此运算符通过定义 QT_NO_CAST_FROM_ASCII when you compile your applications. This can be useful if you want to ensure that all user-visible strings go through QObject::tr (), for example.
该函数在 Qt 5.0 引入。
[since 5.8]
QLatin1Char
QLatin1String::
operator[]
(
qsizetype
pos
) const
返回字符位于位置 pos 在此对象。
注意: This function performs no error checking. The behavior is undefined when pos < 0 or pos >= size ().
该函数在 Qt 5.8 引入。
另请参阅 at ().
返回
true
若字符串
s1
is lexically not equal to string
s2
;否则返回
false
.
返回
true
if char
ch
is lexically not equal to string
s
;否则返回
false
.
返回
true
若字符串
s
is lexically not equal to char
ch
;否则返回
false
.
返回
true
if string view
s1
is lexically not equal to string
s2
;否则返回
false
.
返回
true
若字符串
s1
is lexically not equal to string view
s2
;否则返回
false
.
返回
true
if const char pointer
s1
is lexically not equal to string
s2
;否则返回
false
.
返回
true
若字符串
s1
词法上小于字符串
s2
;否则返回
false
.
返回
true
if char
ch
词法上小于字符串
s
;否则返回
false
.
返回
true
若字符串
s
is lexically less than char
ch
;否则返回
false
.
返回
true
if string view
s1
词法上小于字符串
s2
;否则返回
false
.
返回
true
若字符串
s1
is lexically less than string view
s2
;否则返回
false
.
返回
true
if const char pointer
s1
词法上小于字符串
s2
;否则返回
false
.
返回
true
若字符串
s1
词法上 <= 字符串
s2
;否则返回
false
.
返回
true
if char
ch
词法上 <= 字符串
s
;否则返回
false
.
返回
true
若字符串
s
is lexically less than or equal to char
ch
;否则返回
false
.
返回
true
if string view
s1
词法上 <= 字符串
s2
;否则返回
false
.
返回
true
若字符串
s1
is lexically less than or equal to string view
s2
;否则返回
false
.
返回
true
if const char pointer
s1
词法上 <= 字符串
s2
;否则返回
false
.
返回
true
若字符串
s1
is lexically equal to string
s2
;否则返回
false
.
返回
true
if char
ch
is lexically equal to string
s
;否则返回
false
.
返回
true
若字符串
s
is lexically equal to char
ch
;否则返回
false
.
返回
true
if string view
s1
is lexically equal to string
s2
;否则返回
false
.
返回
true
若字符串
s1
is lexically equal to string view
s2
;否则返回
false
.
返回
true
if const char pointer
s1
is lexically equal to string
s2
;否则返回
false
.
返回
true
若字符串
s1
词法上大于字符串
s2
;否则返回
false
.
返回
true
if char
ch
词法上大于字符串
s
;否则返回
false
.
返回
true
若字符串
s
is lexically greater than char
ch
;否则返回
false
.
返回
true
if string view
s1
词法上大于字符串
s2
;否则返回
false
.
返回
true
若字符串
s1
is lexically greater than string view
s2
;否则返回
false
.
返回
true
if const char pointer
s1
词法上大于字符串
s2
;否则返回
false
.
返回
true
若字符串
s1
词法上大于等于字符串
s2
;否则返回
false
.
返回
true
if char
ch
词法上大于等于字符串
s
;否则返回
false
.
返回
true
若字符串
s
is lexically greater than or equal to char
ch
;否则返回
false
.
返回
true
if string view
s1
词法上大于等于字符串
s2
;否则返回
false
.
返回
true
若字符串
s1
is lexically greater than or equal to string view
s2
;否则返回
false
.
返回
true
if const char pointer
s1
词法上大于等于字符串
s2
;否则返回
false
.