Sur cette page

Chaînes multilignes

Cette catégorie d'avertissement est indiquée par qmllint à l'adresse [multiline-strings].

La chaîne contient un terminateur de ligne non encapsulé, ce qui est déprécié.

Que s'est-il passé ?

Une chaîne s'étend sur plusieurs lignes.

Pourquoi est-ce mauvais ?

Les chaînes s'étendant sur plusieurs lignes sont une extension non standard d'ECMAScript et sont dépréciées dans QML. Utilisez plutôt des littéraux de modèle.

Exemple

import QtQuick

Item {
    property string multiLine: "first
second
third"

    property string multiLine2: 'first
second
third'
}

Pour corriger cet avertissement, utilisez des caractères de modèle ou remplacez les nouvelles lignes par '\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"
}

© 2026 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.