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
\page qmllint-warnings-and-errors-multiline-strings.html
6
\ingroup qmllint-warnings-and-errors
7
8
\title Multiline strings
9
\brief [multiline-strings] A string is spanning over multiple lines.
10
11
\qmllintwarningcategory multiline-strings
12
13
\section1 String contains unescaped line terminator, which is deprecated
14
15
\section2 What happened?
16
A string spans over multiple lines.
17
18
\section2 Why is this bad?
19
Strings spanning multiple lines are a non-standard extension
20
of ECMAScript and deprecated in QML. Use template literals instead.
21
22
\section2 Example
23
\qml
24
import QtQuick
25
26
Item {
27
property string multiLine: "first
28
second
29
third"
30
31
property string multiLine2: 'first
32
second
33
third'
34
}
35
36
\endqml
37
To fix this warning, use template literals or, alternatively,
38
replace the newlines with '\n':
39
\qml
40
import QtQuick
41
42
Item {
43
property string multiLine: `first
44
second
45
third`
46
property string multiLine2: `first
47
second
48
third`
49
50
property string alternative: "first\nsecond\nthird"
51
property string alternative2: "first\n" +
52
"second\n" +
53
"third"
54
}
55
\endqml
56
*/
qtdeclarative
src
qml
doc
src
qmllint
multiline-strings.qdoc
Generated on
for Qt by
1.14.0