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
qqmlpreviewhandler.h
Go to the documentation of this file.
1// Copyright (C) 2018 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 QQMLPREVIEWHANDLER_H
5#define QQMLPREVIEWHANDLER_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include "qqmlpreviewposition.h"
19
20#include <QtCore/qobject.h>
21#include <QtCore/qvector.h>
22#include <QtCore/qrect.h>
23#include <QtCore/qpointer.h>
24#include <QtCore/qelapsedtimer.h>
25#include <QtQml/qqmlengine.h>
26
28
29class QQmlEngine;
30class QQuickItem;
31class QQmlPreviewUrlInterceptor;
32class QQuickWindow;
33
35{
37public:
38 explicit QQmlPreviewHandler(QObject *parent = nullptr);
40
42
45
46 void loadUrl(const QUrl &url);
47 void rerun();
48 void zoom(qreal newFactor);
49
50 void clear();
51
63
65 void error(const QString &message);
66 void fps(const FpsInfo &info);
67
68protected:
69 bool eventFilter(QObject *obj, QEvent *event) override;
70private:
71 void doZoom();
72 void tryCreateObject();
73 void showObject(QObject *object);
74 void setCurrentWindow(QQuickWindow *window);
75
76 void beforeSynchronizing();
77 void afterSynchronizing();
78 void beforeRendering();
79 void frameSwapped();
80
81 void fpsTimerHit();
82
83 QScopedPointer<QQuickItem> m_dummyItem;
84 QList<QQmlEngine *> m_engines;
85 QPointer<QQuickItem> m_currentRootItem;
86 QVector<QPointer<QObject>> m_createdObjects;
87 QScopedPointer<QQmlComponent> m_component;
88 QPointer<QQuickWindow> m_currentWindow;
89 qreal m_zoomFactor = 1.0;
90 bool m_supportsMultipleWindows;
91 QQmlPreviewPosition m_lastPosition;
92
93 QTimer m_fpsTimer;
94
95 struct FrameTime {
96 void beginFrame();
97 void recordFrame();
98 void endFrame();
99 void reset();
100
101 QElapsedTimer timer;
102 qint64 elapsed = -1;
103 quint16 min = std::numeric_limits<quint16>::max();
104 quint16 max = 0;
105 quint16 total = 0;
106 quint16 number = 0;
107 };
108
109 FrameTime m_rendering;
110 FrameTime m_synchronizing;
111};
112
114
116
117#endif // QQMLPREVIEWHANDLER_H
\inmodule QtCore
\inmodule QtCore
Definition qcoreevent.h:45
\inmodule QtCore
Definition qobject.h:103
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
The QQmlEngine class provides an environment for instantiating QML components.
Definition qqmlengine.h:57
void zoom(qreal newFactor)
QQuickItem * currentRootItem()
bool eventFilter(QObject *obj, QEvent *event) override
Filters events if this object has been installed as an event filter for the watched object.
void fps(const FpsInfo &info)
void removeEngine(QQmlEngine *engine)
void error(const QString &message)
void addEngine(QQmlEngine *engine)
void loadUrl(const QUrl &url)
QQmlPreviewHandler(QObject *parent=nullptr)
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qtimer.h:20
\inmodule QtCore
Definition qurl.h:94
Combined button and popup list for selecting options.
#define Q_DECLARE_METATYPE(TYPE)
Definition qmetatype.h:1525
GLuint GLsizei const GLchar * message
struct _cl_event * event
GLhandleARB obj
[2]
GLboolean reset
#define Q_OBJECT
#define Q_SIGNALS
unsigned short quint16
Definition qtypes.h:48
long long qint64
Definition qtypes.h:60
double qreal
Definition qtypes.h:187
QUrl url("example.com")
[constructor-url-reference]
aWidget window() -> setWindowTitle("New Window Title")
[2]
QHostInfo info
[0]
QJSEngine engine
[0]