On this page

Eval

This warning category is spelled [eval] by qmllint.

Do not use eval

What happened?

You used eval in your code.

Why is that bad?

The eval method is slow and potentially dangerous. eval executes its argument as if it were its own JavaScript script, which adds some overhead to the execution. The argument passed to eval is potentially a vector for remote code execution attacks.

Example

import QtQuick

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

To fix this warning, rewrite the code so that it doesn't contain any eval calls.

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.