1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQMLEXPRESSION_H
5#define QQMLEXPRESSION_H
6
7#include <QtQml/qqmlerror.h>
8#include <QtQml/qqmlscriptstring.h>
9
10#include <QtCore/qobject.h>
11#include <QtCore/qvariant.h>
12
13QT_BEGIN_NAMESPACE
14
15
16class QString;
17class QQmlEngine;
18class QQmlContext;
19class QQmlExpressionPrivate;
20class QQmlContextData;
21class Q_QML_EXPORT QQmlExpression : public QObject
22{
23 Q_OBJECT
24public:
25 QQmlExpression();
26 QQmlExpression(QQmlContext *, QObject *, const QString &, QObject * = nullptr);
27 explicit QQmlExpression(const QQmlScriptString &, QQmlContext * = nullptr, QObject * = nullptr, QObject * = nullptr);
28 ~QQmlExpression() override;
29
30 QQmlEngine *engine() const;
31 QQmlContext *context() const;
32
33 QString expression() const;
34 void setExpression(const QString &);
35
36 bool notifyOnValueChanged() const;
37 void setNotifyOnValueChanged(bool);
38
39 QString sourceFile() const;
40 int lineNumber() const;
41 int columnNumber() const;
42 void setSourceLocation(const QString &fileName, int line, int column = 0);
43
44 QObject *scopeObject() const;
45
46 bool hasError() const;
47 void clearError();
48 QQmlError error() const;
49
50 QVariant evaluate(bool *valueIsUndefined = nullptr);
51
52Q_SIGNALS:
53 void valueChanged();
54
55private:
56 QQmlExpression(QQmlExpressionPrivate &dd, QObject *parent);
57
58 Q_DISABLE_COPY(QQmlExpression)
59 Q_DECLARE_PRIVATE(QQmlExpression)
60 friend class QQmlDebugger;
61 friend class QQmlContext;
62};
63
64QT_END_NAMESPACE
65
66#endif // QQMLEXPRESSION_H
67
68

source code of qtdeclarative/src/qml/qml/qqmlexpression.h