Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
eval.qdoc
Go to the documentation of this file.
1
// Copyright (C) 2026 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4
/*!
5
\ingroup qmllint-warnings-and-errors
6
7
\title Eval
8
\brief [eval] Usage of eval.
9
10
\qmllintwarningcategory eval
11
12
\section1 Do not use eval
13
14
\section2 What happened?
15
You used \c {eval} in your code.
16
17
\section2 Why is that bad?
18
The \c{eval} method is slow and potentially dangerous. \c{eval} executes its
19
argument as if it were its own JavaScript script, which adds some overhead to the
20
execution. The argument passed to \c{eval} is potentially a vector for remote
21
code execution attacks.
22
23
\section2 Example
24
\qml
25
import QtQuick
26
27
Item {
28
function f() {
29
let myString = "x",
30
myObject = {
31
x: 10
32
},
33
value = eval("myObject." + myString);
34
}
35
}
36
\endqml
37
To fix this warning, rewrite the code so that it doesn't contain any \c {eval}
38
calls.
39
\qml
40
import QtQuick
41
42
Item {
43
function f() {
44
let myString = "x",
45
myObject = {
46
x: 10
47
},
48
value = myObject[myString];
49
}
50
}
51
\endqml
52
*/
qtdeclarative
src
qml
doc
src
qmllint
eval.qdoc
Generated on
for Qt by
1.16.1