Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qqmlcontext.h
Go to the documentation of this file.
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 QQMLCONTEXT_H
5#define QQMLCONTEXT_H
6
7#include <QtCore/qurl.h>
8#include <QtCore/qobject.h>
9#include <QtCore/qlist.h>
10#include <QtCore/qpair.h>
11#include <QtQml/qjsvalue.h>
12#include <QtCore/qmetatype.h>
13#include <QtCore/qvariant.h>
14
16
17
18class QString;
19class QQmlEngine;
21class QQmlCompositeTypeData;
22class QQmlContextData;
23
24class Q_QML_EXPORT QQmlContext : public QObject
25{
27 Q_DECLARE_PRIVATE(QQmlContext)
28
29public:
31
32 QQmlContext(QQmlEngine *parent, QObject *objParent = nullptr);
33 QQmlContext(QQmlContext *parent, QObject *objParent = nullptr);
34 ~QQmlContext() override;
35
36 bool isValid() const;
37
38 QQmlEngine *engine() const;
39 QQmlContext *parentContext() const;
40
41 QObject *contextObject() const;
42 void setContextObject(QObject *);
43
44 QVariant contextProperty(const QString &) const;
45 void setContextProperty(const QString &, QObject *);
46 void setContextProperty(const QString &, const QVariant &);
47 void setContextProperties(const QList<PropertyPair> &properties);
48
49 QString nameForObject(const QObject *) const;
50 QObject *objectForName(const QString &) const;
51
52 QUrl resolvedUrl(const QUrl &) const;
53
54 void setBaseUrl(const QUrl &);
55 QUrl baseUrl() const;
56
57 QJSValue importedScript(const QString &name) const;
58
59private:
60 friend class QQmlEngine;
61 friend class QQmlEnginePrivate;
62 friend class QQmlExpression;
64 friend class QQmlComponent;
66 friend class QQmlScriptPrivate;
67 friend class QQmlContextData;
68 QQmlContext(QQmlContextPrivate &dd, QObject *parent = nullptr);
69 QQmlContext(QQmlEngine *, bool);
70 Q_DISABLE_COPY(QQmlContext)
71};
73
74#endif // QQMLCONTEXT_H
The QJSValue class acts as a container for Qt/JavaScript data types.
Definition qjsvalue.h:31
\inmodule QtCore
Definition qobject.h:103
The QQmlComponent class encapsulates a QML component definition.
The QQmlContext class defines a context within a QML engine.
Definition qqmlcontext.h:25
The QQmlEngine class provides an environment for instantiating QML components.
Definition qqmlengine.h:57
The QQmlExpression class evaluates JavaScript in a QML context.
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qurl.h:94
\inmodule QtCore
Definition qvariant.h:65
Combined button and popup list for selecting options.
static const QCssKnownValue properties[NumProperties - 1]
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLuint name
static QUrl resolvedUrl(const QUrl &url, const QQmlRefPointer< QQmlContextData > &context)
#define Q_OBJECT
QUrl baseUrl
QJSEngine engine
[0]