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
qquickwidget.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 QQUICKWIDGET_H
5#define QQUICKWIDGET_H
6
7#include <QtWidgets/qwidget.h>
8#include <QtQuick/qquickwindow.h>
9#include <QtCore/qurl.h>
10#include <QtQuickWidgets/qtquickwidgetsglobal.h>
11#include <QtGui/qimage.h>
12
14
15class QQmlEngine;
16class QQmlContext;
17class QQmlError;
18class QQuickItem;
19class QQmlComponent;
20
22class Q_QUICKWIDGETS_EXPORT QQuickWidget : public QWidget
23{
25 Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode)
26 Q_PROPERTY(Status status READ status NOTIFY statusChanged)
27 Q_PROPERTY(QUrl source READ source WRITE setSource DESIGNABLE true)
28
29public:
30 explicit QQuickWidget(QWidget *parent = nullptr);
32 explicit QQuickWidget(const QUrl &source, QWidget *parent = nullptr);
33 ~QQuickWidget() override;
34
35 QUrl source() const;
36
37 QQmlEngine* engine() const;
38 QQmlContext* rootContext() const;
39
40 QQuickItem *rootObject() const;
41
42 enum ResizeMode { SizeViewToRootObject, SizeRootObjectToView };
43 Q_ENUM(ResizeMode)
44 ResizeMode resizeMode() const;
45 void setResizeMode(ResizeMode);
46
47 enum Status { Null, Ready, Loading, Error };
48 Q_ENUM(Status)
49 Status status() const;
50
51 QList<QQmlError> errors() const;
52
53 QSize sizeHint() const override;
54 QSize initialSize() const;
55
56 void setFormat(const QSurfaceFormat &format);
57 QSurfaceFormat format() const;
58
59 QImage grabFramebuffer() const;
60
61 void setClearColor(const QColor &color);
62
63 QQuickWindow *quickWindow() const;
64
65public Q_SLOTS:
66 void setSource(const QUrl&);
67 void setContent(const QUrl& url, QQmlComponent *component, QObject *item);
68
71 void sceneGraphError(QQuickWindow::SceneGraphError error, const QString &message);
72
73private Q_SLOTS:
74 // ### Qt 6: make these truly private slots through Q_PRIVATE_SLOT
75 void continueExecute();
76 void createFramebufferObject();
77 void destroyFramebufferObject();
78 void triggerUpdate();
79 void propagateFocusObjectChanged(QObject *focusObject);
80
81protected:
82 void resizeEvent(QResizeEvent *) override;
83 void timerEvent(QTimerEvent*) override;
84
85 void keyPressEvent(QKeyEvent *) override;
86 void keyReleaseEvent(QKeyEvent *) override;
87 void mousePressEvent(QMouseEvent *) override;
88 void mouseReleaseEvent(QMouseEvent *) override;
89 void mouseMoveEvent(QMouseEvent *) override;
90 void mouseDoubleClickEvent(QMouseEvent *) override;
91
92 void showEvent(QShowEvent *) override;
93 void hideEvent(QHideEvent *) override;
94
95 void focusInEvent(QFocusEvent * event) override;
96 void focusOutEvent(QFocusEvent * event) override;
97
98#if QT_CONFIG(wheelevent)
99 void wheelEvent(QWheelEvent *) override;
100#endif
101
102#if QT_CONFIG(quick_draganddrop)
103 void dragEnterEvent(QDragEnterEvent *) override;
104 void dragMoveEvent(QDragMoveEvent *) override;
105 void dragLeaveEvent(QDragLeaveEvent *) override;
106 void dropEvent(QDropEvent *) override;
107#endif
108
109 bool event(QEvent *) override;
110 void paintEvent(QPaintEvent *event) override;
111 bool focusNextPrevChild(bool next) override;
112
113private:
114 Q_DISABLE_COPY(QQuickWidget)
115 Q_DECLARE_PRIVATE(QQuickWidget)
116};
117
119
120#endif // QQuickWidget_H
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
\inmodule QtCore
Definition qcoreevent.h:45
The QFocusEvent class contains event parameters for widget focus events.
Definition qevent.h:470
The QHideEvent class provides an event which is sent after a widget is hidden.
Definition qevent.h:586
\inmodule QtGui
Definition qimage.h:37
The QKeyEvent class describes a key event.
Definition qevent.h:424
\inmodule QtGui
Definition qevent.h:196
\inmodule QtCore
Definition qobject.h:103
The QPaintEvent class contains event parameters for paint events.
Definition qevent.h:486
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 QQmlError class encapsulates a QML error.
Definition qqmlerror.h:18
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
The QQuickWidget class provides a widget for displaying a Qt Quick user interface.
ResizeMode
This enum specifies how to resize the view.
void sceneGraphError(QQuickWindow::SceneGraphError error, const QString &message)
This signal is emitted when an error occurred during scene graph initialization.
void statusChanged(QQuickWidget::Status)
This signal is emitted when the component's current status changes.
Status
Specifies the loading status of the QQuickWidget.
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
The QResizeEvent class contains event parameters for resize events.
Definition qevent.h:548
The QShowEvent class provides an event that is sent when a widget is shown.
Definition qevent.h:578
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
The QSurfaceFormat class represents the format of a QSurface. \inmodule QtGui.
\inmodule QtCore
Definition qcoreevent.h:366
\inmodule QtCore
Definition qurl.h:94
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
void statusChanged(QQmlComponent::Status status)
[1]
Definition qlogging.cpp:11
widget setFormat(format)
short next
Definition keywords.cpp:445
Combined button and popup list for selecting options.
DBusConnection const char DBusError * error
GLuint color
[2]
GLuint GLsizei const GLchar * message
GLint GLsizei GLsizei GLenum format
GLsizei GLsizei GLchar * source
struct _cl_event * event
static qreal component(const QPointF &point, unsigned int i)
#define Q_ENUM(x)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_SLOTS
#define Q_SIGNALS
#define explicit
QUrl url("example.com")
[constructor-url-reference]
QGraphicsItem * item
QJSEngine engine
[0]