Avec
Cette catégorie d'avertissement est orthographiée [with] par qmllint.
Avec des déclarations
Qu'est-ce qui s'est passé ?
L'instruction JavaScript with a été utilisée.
Pourquoi est-ce mauvais ?
Les instructions With peuvent provoquer des faux positifs lors de l'analyse d'identificateurs non qualifiés. En outre, les instructions with sont considérées comme obsolètes par la dernière norme JavaScript.
Exemple
import QtQuick Item { function f() { with (Math) { return PI } } }
Pour corriger cet avertissement, remplacez l'instruction with par une propriété de déstructuration :
import QtQuick Item { function f() { const { PI } = Math; return PI } }
Remarque : vous trouverez d'autres idées de remplacement ici.
© 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.