Qt 6.x
The Qt SDK
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:469
The QHideEvent class provides an event which is sent after a widget is hidden.
Definition qevent.h:585
\inmodule QtGui
Definition qimage.h:37
The QKeyEvent class describes a key event.
Definition qevent.h:423
Definition qlist.h:74
\inmodule QtGui
Definition qevent.h:195
\inmodule QtCore
Definition qobject.h:90
virtual void timerEvent(QTimerEvent *event)
This event handler can be reimplemented in a subclass to receive timer events for the object.
Definition qobject.cpp:1433
The QPaintEvent class contains event parameters for paint events.
Definition qevent.h:485
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:64
\module QtQuickWidgets \title Qt Quick Widgets C++ Classes
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:547
The QShowEvent class provides an event that is sent when a widget is shown.
Definition qevent.h:577
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
The QSurfaceFormat class represents the format of a QSurface. \inmodule QtGui.
\inmodule QtCore
Definition qcoreevent.h:359
\inmodule QtCore
Definition qurl.h:94
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
virtual void hideEvent(QHideEvent *event)
This event handler can be reimplemented in a subclass to receive widget hide events.
virtual void mouseMoveEvent(QMouseEvent *event)
This event handler, for event event, can be reimplemented in a subclass to receive mouse move events ...
Definition qwidget.cpp:9507
virtual void mousePressEvent(QMouseEvent *event)
This event handler, for event event, can be reimplemented in a subclass to receive mouse press events...
Definition qwidget.cpp:9529
virtual void mouseDoubleClickEvent(QMouseEvent *event)
This event handler, for event event, can be reimplemented in a subclass to receive mouse double click...
Definition qwidget.cpp:9576
virtual void focusInEvent(QFocusEvent *event)
This event handler can be reimplemented in a subclass to receive keyboard focus events (focus receive...
Definition qwidget.cpp:9711
virtual void mouseReleaseEvent(QMouseEvent *event)
This event handler, for event event, can be reimplemented in a subclass to receive mouse release even...
Definition qwidget.cpp:9554
virtual void keyReleaseEvent(QKeyEvent *event)
This event handler, for event event, can be reimplemented in a subclass to receive key release events...
Definition qwidget.cpp:9687
virtual bool focusNextPrevChild(bool next)
Finds a new widget to give the keyboard focus to, as appropriate for Tab and Shift+Tab,...
Definition qwidget.cpp:6800
QSize sizeHint
the recommended size for the widget
Definition qwidget.h:148
virtual void focusOutEvent(QFocusEvent *event)
This event handler can be reimplemented in a subclass to receive keyboard focus events (focus lost) f...
Definition qwidget.cpp:9737
virtual void resizeEvent(QResizeEvent *event)
This event handler can be reimplemented in a subclass to receive widget resize events which are passe...
Definition qwidget.cpp:9868
virtual void keyPressEvent(QKeyEvent *event)
This event handler, for event event, can be reimplemented in a subclass to receive key press events f...
Definition qwidget.cpp:9652
virtual void paintEvent(QPaintEvent *event)
This event handler can be reimplemented in a subclass to receive paint events passed in event.
Definition qwidget.cpp:9829
virtual void showEvent(QShowEvent *event)
This event handler can be reimplemented in a subclass to receive widget show events which are passed ...
void statusChanged(QDeclarativeComponent::Status status)
[1]
Definition qlogging.cpp:9
widget setFormat(format)
short next
Definition keywords.cpp:445
Combined button and popup list for selecting options.
DBusConnection const char DBusError * error
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
QUrl url("example.com")
[constructor-url-reference]
QGraphicsItem * item
QJSEngine engine
[0]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent