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 QQUICKVIEW_H
5#define QQUICKVIEW_H
6
7#include <QtQuick/qquickwindow.h>
8#include <QtCore/qurl.h>
9
10QT_BEGIN_NAMESPACE
11
12class QQmlEngine;
13class QQmlContext;
14class QQmlError;
15class QQuickItem;
16class QQmlComponent;
17
18class QQuickViewPrivate;
19class Q_QUICK_EXPORT QQuickView : public QQuickWindow
20{
21 Q_OBJECT
22 Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode FINAL)
23 Q_PROPERTY(Status status READ status NOTIFY statusChanged FINAL)
24 Q_PROPERTY(QUrl source READ source WRITE setSource DESIGNABLE true FINAL)
25public:
26 explicit QQuickView(QWindow *parent = nullptr);
27 QQuickView(QQmlEngine* engine, QWindow *parent);
28 explicit QQuickView(const QUrl &source, QWindow *parent = nullptr);
29 QQuickView(const QUrl &source, QQuickRenderControl *renderControl);
30 ~QQuickView() override;
31
32 QUrl source() const;
33
34 QQmlEngine* engine() const;
35 QQmlContext* rootContext() const;
36
37 QQuickItem *rootObject() const;
38
39 enum ResizeMode { SizeViewToRootObject, SizeRootObjectToView };
40 Q_ENUM(ResizeMode)
41 ResizeMode resizeMode() const;
42 void setResizeMode(ResizeMode);
43
44 enum Status { Null, Ready, Loading, Error };
45 Q_ENUM(Status)
46 Status status() const;
47
48 QList<QQmlError> errors() const;
49
50 QSize sizeHint() const;
51 QSize initialSize() const;
52
53public Q_SLOTS:
54 void setSource(const QUrl&);
55 void setInitialProperties(const QVariantMap &initialProperties);
56 void setContent(const QUrl& url, QQmlComponent *component, QObject *item);
57
58Q_SIGNALS:
59 void statusChanged(QQuickView::Status);
60
61private Q_SLOTS:
62 void continueExecute();
63
64protected:
65 void resizeEvent(QResizeEvent *) override;
66 void timerEvent(QTimerEvent*) override;
67
68 void keyPressEvent(QKeyEvent *) override;
69 void keyReleaseEvent(QKeyEvent *) override;
70 void mousePressEvent(QMouseEvent *) override;
71 void mouseReleaseEvent(QMouseEvent *) override;
72 void mouseMoveEvent(QMouseEvent *) override;
73private:
74 Q_DISABLE_COPY(QQuickView)
75 Q_DECLARE_PRIVATE(QQuickView)
76};
77
78QT_END_NAMESPACE
79
80#endif // QQUICKVIEW_H
81

source code of qtdeclarative/src/quick/items/qquickview.h