Sur cette page

Chaînes multilignes

Cette catégorie d'avertissement est orthographiée « [multiline-strings] » par qmllint.

La chaîne contient un caractère de fin de ligne non échappé, ce qui est déprécié

Que s'est-il passé ?

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

Pourquoi est-ce un problème ?

Les chaînes s'étendant sur plusieurs lignes constituent une extension non standard d'ECMAScript et sont obsolètes 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 littéraux de modèle ou, à défaut, remplacez les sauts de ligne 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.