Mehrzeilige Zeichenketten

Diese Warnkategorie wird von qmllint [multiline-strings] geschrieben.

String enthält nicht abgeschlossene Zeilenbegrenzer, die veraltet sind

Was ist passiert?

Eine Zeichenkette erstreckt sich über mehrere Zeilen.

Warum ist das schlecht?

Strings, die sich über mehrere Zeilen erstrecken, sind eine Nicht-Standard-Erweiterung von ECMAScript und in QML deprecated. Verwenden Sie stattdessen Template-Literale.

Beispiel

import QtQuick

Item {
    property string multiLine: "first
second
third"

    property string multiLine2: 'first
second
third'
}

Um diese Warnung zu beheben, verwenden Sie Template-Literale oder ersetzen Sie alternativ die Zeilenumbrüche durch '\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.