マルチライン文字列

この警告カテゴリーはqmllintによって[multiline-strings]

文字列が非推奨のエスケープされていない行終端記号を含んでいます。

何が起こりましたか?

文字列が複数行にまたがっています。

なぜ悪いのですか?

複数行にまたがる文字列はECMAScriptの非標準拡張であり、QMLでは非推奨です。代わりにテンプレートリテラルを使用してください。

import QtQuick

Item {
    property string multiLine: "first
second
third"

    property string multiLine2: 'first
second
third'
}

この警告を修正するには、テンプレートリテラルを使用するか、改行を'˶n'に置き換えてください:

import QtQuick

Item {
    property string multiLine: `first
second
third`
    property string multiLine2: `first
second
third`

    property string alternative: "first\nsecond\nthird"
    property string alternative2: "first\n" +
"second\n" +
"third"
}

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.