11#include <QtQml/qqmlengine.h>
12#include <private/qqmlengine_p.h>
13#include <private/qv4qobjectwrapper_p.h>
14#include <QtCore/qbasictimer.h>
54 qWarning() <<
"QQuickView: invalid qml engine.";
78 q,
SLOT(continueExecute()));
94 q,
SLOT(continueExecute()));
100 const QRectF &oldGeometry)
277 d->initialProperties = initialProperties;
291 if (
d->component &&
d->component->isError()) {
292 const QList<QQmlError> errorList =
d->component->errors();
301 if (!
d->setRootObject(
item))
324 return d->engine ?
const_cast<QQmlEngine *
>(
d->engine.data()) :
nullptr;
337 return d->engine ?
d->engine.data()->rootContext() :
nullptr;
386 QList<QQmlError> errs;
389 errs =
d->component->errors();
420 if (
d->resizeMode ==
mode)
430 d->resizeMode =
mode;
455 if (newSize.
isValid() && newSize !=
q->size()) {
462 if (needToUpdateWidth && needToUpdateHeight)
464 else if (needToUpdateWidth)
466 else if (needToUpdateHeight)
474 int widthCandidate = -1;
475 int heightCandidate = -1;
480 if (widthCandidate > 0) {
483 if (heightCandidate > 0) {
492 return d->resizeMode;
498void QQuickView::continueExecute()
503 if (
d->component->isError()) {
504 const QList<QQmlError> errorList =
d->component->errors();
513 std::unique_ptr<QObject>
obj(
d->initialProperties.empty()
514 ?
d->component->create()
515 :
d->
component->createWithInitialProperties(
d->initialProperties));
517 if (
d->component->isError()) {
518 const QList<QQmlError> errorList =
d->component->errors();
529 if (
d->source.isEmpty())
530 d->source =
d->component->url();
532 if (
d->setRootObject(
obj.get()))
559 sgItem->setParentItem(
q->QQuickWindow::contentItem());
570 if (qobject_cast<QWindow *>(
obj)) {
571 qWarning() <<
"QQuickView does not support using a window as a root item." <<
Qt::endl
573 <<
"If you wish to create your root window from QML, consider using QQmlApplicationEngine instead." <<
Qt::endl;
577 qWarning() <<
"QQuickView only supports loading of root objects that derive from QQuickItem." <<
Qt::endl
579 <<
"Ensure your QML code is written for QtQuick 2, and uses a root that is or" <<
Qt::endl
580 <<
"inherits from QtQuick's Item (not a Timer, QtObject, etc)." <<
Qt::endl;
592 if (!e || e->
timerId() ==
d->resizetimer.timerId()) {
594 d->resizetimer.stop();
605 QSize rootObjectSize =
d->rootObjectSize();
606 if (rootObjectSize.
isEmpty()) {
609 return rootObjectSize;
623 return d->initialSize;
682#include "moc_qquickview.cpp"
void start(int msec, QObject *obj)
\obsolete Use chrono overload instead.
QV4::ExecutionEngine * handle() const
The QKeyEvent class describes a key event.
void void Q_DECL_COLD_FUNCTION void warning(const char *msg,...) const Q_ATTRIBUTE_FORMAT_PRINTF(2
Logs a warning message specified with format msg.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
T * data() const noexcept
bool isNull() const noexcept
The QQmlComponent class encapsulates a QML component definition.
Status
\qmltype Component \instantiates QQmlComponent\inqmlmodule QtQml
bool isLoading() const
Returns true if status() == QQmlComponent::Loading.
The QQmlContext class defines a context within a QML engine.
The QQmlEngine class provides an environment for instantiating QML components.
QQmlIncubationController * incubationController() const
Returns the currently set incubation controller, or 0 if no controller has been set.
static void setContextForObject(QObject *, QQmlContext *)
Sets the QQmlContext for the object to context.
void setIncubationController(QQmlIncubationController *)
Sets the engine's incubation controller.
QQmlContext * rootContext() const
Returns the engine's root context.
The QQmlError class encapsulates a QML error.
virtual void itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &)
static QQuickItemPrivate * get(QQuickItem *item)
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
void setSize(const QSizeF &size)
void setFlag(Flag flag, bool enabled=true)
Enables the specified flag for this item if enabled is true; if enabled is false, the flag is disable...
qreal width
This property holds the width of this item.
qreal height
This property holds the height of this item.
The QQuickRenderControl class provides a mechanism for rendering the Qt Quick scenegraph onto an offs...
ExecuteState executeHelper()
QSize rootObjectSize() const
bool setRootObject(QObject *)
QQuickView::ResizeMode resizeMode
QPointer< QQuickItem > root
void init(QQmlEngine *e=nullptr)
QPointer< QQmlEngine > engine
QQmlComponent * component
void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &) override
The QQuickView class provides a window for displaying a Qt Quick user interface.
QQuickView(QWindow *parent=nullptr)
Constructs a QQuickView with the given parent.
void setContent(const QUrl &url, QQmlComponent *component, QObject *item)
~QQuickView() override
Destroys the QQuickView.
QUrl source
The URL of the source of the QML component.
ResizeMode resizeMode
whether the view should resize the window contents
void mousePressEvent(QMouseEvent *) override
\reimp
QList< QQmlError > errors() const
Return the list of errors that occurred during the last compile or create operation.
void keyReleaseEvent(QKeyEvent *) override
\reimp
void keyPressEvent(QKeyEvent *) override
\reimp
QSize initialSize() const
Returns the initial size of the root object.
void setResizeMode(ResizeMode)
void timerEvent(QTimerEvent *) override
Status status
The component's current \l{QQuickView::Status} {status}.
QQmlEngine * engine() const
Returns a pointer to the QQmlEngine used for instantiating QML Components.
QQmlContext * rootContext() const
This function returns the root of the context hierarchy.
ResizeMode
This enum specifies how to resize the view.
void resizeEvent(QResizeEvent *) override
void loadFromModule(QAnyStringView uri, QAnyStringView typeName)
Status
Specifies the loading status of the QQuickView.
void mouseMoveEvent(QMouseEvent *) override
\reimp
void setSource(const QUrl &)
Sets the source to the url, loads the QML component and instantiates it.
void setInitialProperties(const QVariantMap &initialProperties)
Sets the initial properties initialProperties with which the QML component gets initialized after cal...
QQuickItem * rootObject() const
Returns the view's root \l {QQuickItem} {item}.
void statusChanged(QQuickView::Status)
This signal is emitted when the component's current status changes.
void mouseReleaseEvent(QMouseEvent *) override
\reimp
QQuickRootItem * contentItem
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
void mousePressEvent(QMouseEvent *) override
\reimp
void resizeEvent(QResizeEvent *) override
\reimp
void mouseReleaseEvent(QMouseEvent *) override
\reimp
void mouseMoveEvent(QMouseEvent *) override
\reimp
void keyReleaseEvent(QKeyEvent *) override
\reimp
void keyPressEvent(QKeyEvent *) override
\reimp
\inmodule QtCore\reentrant
The QResizeEvent class contains event parameters for resize events.
constexpr void setWidth(int w) noexcept
Sets the width to the given width.
constexpr bool isEmpty() const noexcept
Returns true if either of the width and height is less than or equal to 0; otherwise returns false.
constexpr void setHeight(int h) noexcept
Sets the height to the given height.
constexpr bool isValid() const noexcept
Returns true if both the width and height is equal to or greater than 0; otherwise returns false.
int timerId() const
Returns the unique timer identifier, which is the same identifier as returned from QObject::startTime...
QSize size() const override
Returns the size of the window excluding any window frame.
void statusChanged(QQmlComponent::Status status)
[1]
Combined button and popup list for selecting options.
QTextStream & endl(QTextStream &stream)
Writes '\n' to the stream and flushes the stream.
DBusConnection const char DBusError * error
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
GLsizei GLsizei GLchar * source
GLdouble GLdouble GLdouble GLdouble q
static qreal component(const QPointF &point, unsigned int i)
void QQml_setParent_noEvent(QObject *object, QObject *parent)
Makes the object a child of parent.
QLatin1StringView QLatin1String
QUrl url("example.com")
[constructor-url-reference]
myObject disconnect()
[26]
static void ensureWrapper(ExecutionEngine *engine, QObject *object)