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?
16A string spans over multiple lines.
17
18\section2 Why is this bad?
19Strings spanning multiple lines are a non-standard extension
20of ECMAScript and deprecated in QML. Use template literals instead.
21
22\section2 Example
23\qml
24import QtQuick
25
26Item {
27 property string multiLine: "first
28second
29third"
30
31 property string multiLine2: 'first
32second
33third'
34}
35
36\endqml
37To fix this warning, use template literals or, alternatively,
38replace the newlines with '\n':
39\qml
40import QtQuick
41
42Item {
43 property string multiLine: `first
44second
45third`
46 property string multiLine2: `first
47second
48third`
49
50 property string alternative: "first\nsecond\nthird"
51 property string alternative2: "first\n" +
52"second\n" +
53"third"
54}
55\endqml
56*/