11#include <QtQml/qqmlengine.h>
12#include <private/qqmlengine_p.h>
13#include <private/qv4qobjectwrapper_p.h>
14#include <QtCore/qbasictimer.h>
55 qWarning() <<
"QQuickView: invalid qml engine.";
71 q,
SLOT(continueExecute()));
221 d->initialProperties = initialProperties;
235 if (
d->component &&
d->component->isError()) {
245 if (!
d->setRootObject(
item))
268 return d->engine ?
const_cast<QQmlEngine *
>(
d->engine.data()) :
nullptr;
281 return d->engine ?
d->engine.data()->rootContext() :
nullptr;
333 errs =
d->component->errors();
364 if (
d->resizeMode ==
mode)
374 d->resizeMode =
mode;
399 if (newSize.
isValid() && newSize !=
q->size()) {
406 if (needToUpdateWidth && needToUpdateHeight)
408 else if (needToUpdateWidth)
410 else if (needToUpdateHeight)
418 int widthCandidate = -1;
419 int heightCandidate = -1;
424 if (widthCandidate > 0) {
427 if (heightCandidate > 0) {
436 return d->resizeMode;
442void QQuickView::continueExecute()
447 if (
d->component->isError()) {
457 std::unique_ptr<QObject>
obj(
d->initialProperties.empty()
458 ?
d->component->create()
459 :
d->
component->createWithInitialProperties(
d->initialProperties));
461 if (
d->component->isError()) {
471 if (
d->setRootObject(
obj.get()))
498 sgItem->setParentItem(
q->QQuickWindow::contentItem());
510 qWarning() <<
"QQuickView does not support using a window as a root item." <<
Qt::endl
512 <<
"If you wish to create your root window from QML, consider using QQmlApplicationEngine instead." <<
Qt::endl;
516 qWarning() <<
"QQuickView only supports loading of root objects that derive from QQuickItem." <<
Qt::endl
518 <<
"Ensure your QML code is written for QtQuick 2, and uses a root that is or" <<
Qt::endl
519 <<
"inherits from QtQuick's Item (not a Timer, QtObject, etc)." <<
Qt::endl;
531 if (!
e ||
e->timerId() ==
d->resizetimer.timerId()) {
533 d->resizetimer.stop();
544 QSize rootObjectSize =
d->rootObjectSize();
545 if (rootObjectSize.
isEmpty()) {
548 return rootObjectSize;
562 return d->initialSize;
621#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
bool isNull() const
Returns true if the referenced object has been destroyed or if there is no referenced object; otherwi...
The QQmlComponent class encapsulates a QML component definition.
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...
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
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.
QSize size() const override
Returns the size of the window excluding any window frame.
void statusChanged(QDeclarativeComponent::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.
QQuickItem * qobject_cast< QQuickItem * >(QObject *o)
QLatin1StringView QLatin1String
QWindow * qobject_cast< QWindow * >(QObject *o)
QUrl url("example.com")
[constructor-url-reference]
myObject disconnect()
[26]
static ReturnedValue wrap(ExecutionEngine *engine, QObject *object)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent