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 | |
10 | QT_BEGIN_NAMESPACE |
11 | |
12 | class QQmlEngine; |
13 | class QQmlContext; |
14 | class QQmlError; |
15 | class QQuickItem; |
16 | class QQmlComponent; |
17 | |
18 | class QQuickViewPrivate; |
19 | class 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) |
25 | public: |
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 | |
53 | public Q_SLOTS: |
54 | void setSource(const QUrl&); |
55 | void setInitialProperties(const QVariantMap &initialProperties); |
56 | void setContent(const QUrl& url, QQmlComponent *component, QObject *item); |
57 | |
58 | Q_SIGNALS: |
59 | void statusChanged(QQuickView::Status); |
60 | |
61 | private Q_SLOTS: |
62 | void continueExecute(); |
63 | |
64 | protected: |
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; |
73 | private: |
74 | Q_DISABLE_COPY(QQuickView) |
75 | Q_DECLARE_PRIVATE(QQuickView) |
76 | }; |
77 | |
78 | QT_END_NAMESPACE |
79 | |
80 | #endif // QQUICKVIEW_H |
81 |