In questa pagina

Eval

Questa categoria di avviso viene indicata da qmllint con il nome " [eval] ".

Non utilizzare eval

Cosa è successo?

Hai utilizzato " eval " nel tuo codice.

Perché è un problema?

Il metodo ` eval ` è lento e potenzialmente pericoloso. ` eval ` esegue il proprio argomento come se fosse un proprio script JavaScript, il che aggiunge un certo sovraccarico all'esecuzione. L'argomento passato a ` eval ` è potenzialmente un vettore per attacchi di esecuzione di codice remoto.

Esempio

import QtQuick

Item {
    function f() {
        let myString = "x",
        myObject = {
            x: 10
        },
        value = eval("myObject." + myString);
    }
}

Per risolvere questo avviso, riscrivi il codice in modo che non contenga alcuna chiamata a ` eval `.

import QtQuick

Item {
    function f() {
        let myString = "x",
        myObject = {
            x: 10
        },
        value = myObject[myString];
    }
}

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