Qt
6.x
The Qt SDK
Loading...
Searching...
No Matches
stringbuilder.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4
#include <QString>
5
6
using namespace
Qt::StringLiterals
;
7
9
QString
foo
;
10
QString
type
=
"long"
;
11
12
foo
=
"vector<"
_L1 +
type
+
">::iterator"
_L1;
13
14
if
(
foo
.
startsWith
(
"("
+
type
+
") 0x"
))
15
...
17
19
#include <QStringBuilder>
20
21
QString
hello
(
"hello"
);
22
QStringView
el
=
QStringView
{
hello
}.mid(2, 3);
23
QLatin1StringView
world
(
"world"
);
24
QString
message
=
hello
%
el
%
world
%
QChar
(
'!'
);
26
28
QString
str
(
"QStringBuilder"
);
29
30
// "s" type is deduced as QStringBuilder<...>
31
auto
s
=
"Like hot glue, "
%
str
%
" concatenates strings"
;
32
33
// Similarly the return type of this lambda is deduced as QStringBuilder<...>
34
auto
concatenateStr
= []() {
35
return
"Like hot glue, "
%
str
%
" concatenates strings"
;
36
};
38
40
QString
s
=
"Like hot glue, "
%
str
%
" concatenates strings"
;
41
42
// With a lambda, specify a trailing return type:
43
auto
concatenateStr
= []() ->
QString
{
44
return
"Like hot glue, "
%
str
%
" concatenates strings"
;
45
};
QChar
\inmodule QtCore
Definition
qchar.h:48
QLatin1StringView
Definition
qlatin1stringview.h:31
QStringView
\inmodule QtCore
Definition
qstringview.h:76
QString
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition
qstring.h:127
QString::startsWith
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition
qstring.cpp:5299
Qt::StringLiterals
Definition
qbytearray.h:716
type
GLenum type
Definition
qopengles2ext.h:150
message
GLuint GLsizei const GLchar * message
Definition
qopengles2ext.h:154
s
GLdouble s
[6]
Definition
qopenglext.h:235
hello
HelloWorldTask * hello
Definition
src_corelib_concurrent_qthreadpool.cpp:13
str
QString str("QStringBuilder")
[5]
el
QStringView el
Definition
stringbuilder.cpp:22
world
QLatin1StringView world("world")
concatenateStr
auto concatenateStr
Definition
stringbuilder.cpp:34
foo
QString foo
[0]
Definition
stringbuilder.cpp:9
qtbase
src
corelib
doc
snippets
qstring
stringbuilder.cpp
Generated by
1.9.7