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
\page qmllint-warnings-and-errors-eval.html
6
\ingroup qmllint-warnings-and-errors
7
8
\title Eval
9
\brief [eval] Usage of eval.
10
11
\qmllintwarningcategory eval
12
13
\section1 Do not use eval
14
15
\section2 What happened?
16
You used \c {eval} in your code.
17
18
\section2 Why is that bad?
19
The \c{eval} method is slow and potentially dangerous. \c{eval} executes its
20
argument as if it were its own JavaScript script, which adds some overhead to the
21
execution. The argument passed to \c{eval} is potentially a vector for remote
22
code execution attacks.
23
24
\section2 Example
25
\qml
26
import QtQuick
27
28
Item {
29
function f() {
30
let myString = "x",
31
myObject = {
32
x: 10
33
},
34
value = eval("myObject." + myString);
35
}
36
}
37
\endqml
38
To fix this warning, rewrite the code so that it doesn't contain any \c {eval}
39
calls.
40
\qml
41
import QtQuick
42
43
Item {
44
function f() {
45
let myString = "x",
46
myObject = {
47
x: 10
48
},
49
value = myObject[myString];
50
}
51
}
52
\endqml
53
*/
qtdeclarative
src
qml
doc
src
qmllint
eval.qdoc
Generated on
for Qt by
1.16.1