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