summaryrefslogtreecommitdiffstats
path: root/src/corelib/doc/snippets/qstring/stringbuilder.cpp
blob: 6b3175d48a257de7c0947f966740fbba86300545 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

using namespace Qt::StringLiterals;

//! [0]
    QString foo;
    QString type = "long";

    foo = "vector<"_L1 + type + ">::iterator"_L1;

    if (foo.startsWith("(" + type + ") 0x"))
        ...
//! [0]

//! [3]
    DEFINES *= QT_USE_QSTRINGBUILDER
//! [3]

//! [5]
    #include <QStringBuilder>

    QString hello("hello");
    QStringView el = QStringView{ hello }.mid(2, 3);
    QLatin1StringView world("world");
    QString message =  hello % el % world % QChar('!');
//! [5]