Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
multiline-strings.qdoc
Go to the documentation of this file.
1
// Copyright (C) 2023 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4
/*!
5
\ingroup qmllint-warnings-and-errors
6
7
\title Multiline strings
8
\brief [multiline-strings] A string is spanning over multiple lines.
9
10
\qmllintwarningcategory multiline-strings
11
12
\section1 String contains unescaped line terminator, which is deprecated
13
14
\section2 What happened?
15
A string spans over multiple lines.
16
17
\section2 Why is this bad?
18
Strings spanning multiple lines are a non-standard extension
19
of ECMAScript and deprecated in QML. Use template literals instead.
20
21
\section2 Example
22
\qml
23
import QtQuick
24
25
Item {
26
property string multiLine: "first
27
second
28
third"
29
30
property string multiLine2: 'first
31
second
32
third'
33
}
34
35
\endqml
36
To fix this warning, use template literals or, alternatively,
37
replace the newlines with '\n':
38
\qml
39
import QtQuick
40
41
Item {
42
property string multiLine: `first
43
second
44
third`
45
property string multiLine2: `first
46
second
47
third`
48
49
property string alternative: "first\nsecond\nthird"
50
property string alternative2: "first\n" +
51
"second\n" +
52
"third"
53
}
54
\endqml
55
*/
qtdeclarative
src
qml
doc
src
qmllint
multiline-strings.qdoc
Generated on
for Qt by
1.16.1