6#include <QtQml/qqmlinfo.h>
8#include <private/qqmlengine_p.h>
9#include <private/qqmlglobal_p.h>
11#include <private/qqmlcomponent_p.h>
12#include <private/qqmlincubator_p.h>
22 :
item(
nullptr),
object(
nullptr), itemContext(
nullptr), incubator(
nullptr), updatingSize(
false),
23 active(true), loadingFromSource(
false), asynchronous(
false), status(computeStatus())
38 if (resizeItem ==
item)
307 if (
d->active == newVal)
311 if (newVal ==
true) {
312 if (
d->loadingFromSource) {
315 loadFromSourceComponent();
320 d->incubator->clear();
321 delete d->itemContext;
322 d->itemContext =
nullptr;
337 d->item->setParentItem(
nullptr);
338 d->item->setVisible(
false);
342 d->object->deleteLater();
379 if (
d->source ==
url)
386 d->loadingFromSource =
true;
394void QQuickLoader::loadFromSource()
397 if (
d->source.isEmpty()) {
407 d->createComponent();
445 if (comp ==
d->component)
450 d->component.setObject(comp,
this);
451 d->loadingFromSource =
false;
454 loadFromSourceComponent();
464void QQuickLoader::loadFromSourceComponent()
480QUrl QQuickLoader::setSourceUrlHelper(
const QUrl &unresolvedUrl)
487 QUrl oldUrl =
d->source;
564 qmlWarning(
this) << QQuickLoader::tr(
"setSource: value is not an object");
570 d->disposeInitialPropertyValues();
584 d->disposeInitialPropertyValues();
611 emit q->progressChanged();
613 emit q->sourceChanged();
615 emit q->sourceComponentChanged();
616 emit q->itemChanged();
659 d->initializeObjectWithInitialProperties(
qmlContext, ipv,
obj, incubatorPriv->requiredProperties());
676 emit q->itemChanged();
686 emit q->itemChanged();
689 emit q->sourceChanged();
691 emit q->sourceComponentChanged();
693 emit q->progressChanged();
705 emit q->sourceChanged();
707 emit q->sourceComponentChanged();
709 emit q->progressChanged();
710 emit q->itemChanged();
719 if (!creationContext)
725 return creationContext;
784 return static_cast<Status>(
d->status);
792 if (
d->loadingFromSource)
793 d->createComponent();
838 return d->component->progress();
879 return d->asynchronous;
885 if (
d->asynchronous ==
a)
891 if (
d->loadingFromSource &&
d->component &&
d->component->isLoading()) {
893 QUrl currentSource =
d->source;
895 d->source = currentSource;
897 }
else if (
d->incubator &&
d->incubator->isLoading()) {
898 d->incubator->forceCompletion();
911 const bool needToUpdateWidth = loaderGeometryChanged &&
q->widthValid();
912 const bool needToUpdateHeight = loaderGeometryChanged &&
q->heightValid();
914 if (needToUpdateWidth && needToUpdateHeight) {
922 if (itemPriv->width.hasBinding())
923 itemPriv->width.takeBinding();
924 if (itemPriv->height.hasBinding())
925 itemPriv->height.takeBinding();
927 }
else if (needToUpdateWidth) {
929 }
else if (needToUpdateHeight) {
958 if (newGeometry != oldGeometry) {
1003 if (
status != newStatus) {
1005 emit q->statusChanged();
1023 qmlWarning(
q) <<
"createComponent: Cannot find a QML engine.";
1028#include <moc_qquickloader_p.cpp>
QV4::ExecutionEngine * handle() const
static QV4::Value * takeManagedValue(QJSValue *jsval)
The QJSValue class acts as a container for Qt/JavaScript data types.
bool isEmpty() const noexcept
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
\threadsafe
void deleteLater()
\threadsafe
static QQmlComponentPrivate * get(QQmlComponent *c)
The QQmlComponent class encapsulates a QML component definition.
Status
\qmltype Component \instantiates QQmlComponent\inqmlmodule QtQml
bool isLoading() const
Returns true if status() == QQmlComponent::Loading.
QQmlContext * creationContext() const
Returns the QQmlContext the component was created in.
Status status
\qmlproperty enumeration Component::status
QList< QQmlError > errors() const
Returns the list of errors that occurred during the last compile or create operation.
CompilationMode
Specifies whether the QQmlComponent should load the component immediately, or asynchonously.
virtual QObject * create(QQmlContext *context=nullptr)
Create an object instance from this component, within the specified context.
static QQmlRefPointer< QQmlContextData > get(QQmlContext *context)
QUrl resolvedUrl(const QUrl &) const
The QQmlContext class defines a context within a QML engine.
void setContextObject(QObject *)
Set the context object.
void warning(const QQmlError &)
The QQmlEngine class provides an environment for instantiating QML components.
static QQmlIncubatorPrivate * get(QQmlIncubator *incubator)
QList< QQmlError > errors() const
Return the list of errors encountered while incubating the object.
void clear()
Clears the incubator.
QObject * object() const
Return the incubated object if the status is Ready, otherwise 0.
Status status() const
Return the current status of the incubator.
Status
Specifies the status of the QQmlIncubator.
void setObject(T *obj, QObject *parent)
virtual void itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &)
virtual qreal getImplicitWidth() const
virtual qreal getImplicitHeight() const
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...
virtual void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry)
void setParentItem(QQuickItem *parent)
void componentComplete() override
\reimp Derived classes should call the base class method before adding their own actions to perform a...
qreal width
This property holds the width of this item.
virtual void itemChange(ItemChange, const ItemChangeData &)
Called when change occurs for this item.
bool isComponentComplete() const
Returns true if construction of the QML component is complete; otherwise returns false.
qreal height
This property holds the height of this item.
ItemChange
Used in conjunction with QQuickItem::itemChange() to notify the item about certain types of changes.
void setInitialState(QObject *) override
Called after the object is first created, but before complex property bindings are evaluated and,...
void statusChanged(Status) override
Called when the status of the incubator changes.
QQmlStrongJSQObjectReference< QQmlComponent > component
void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &oldGeometry) override
void disposeInitialPropertyValues()
void itemImplicitWidthChanged(QQuickItem *) override
QV4::PersistentValue qmlCallingContext
qreal getImplicitWidth() const override
QQuickLoader::Status computeStatus() const
QV4::PersistentValue initialPropertyValues
QQmlContext * itemContext
void setInitialState(QObject *o)
QQuickLoaderIncubator * incubator
void _q_updateSize(bool loaderGeometryChanged=true)
void itemImplicitHeightChanged(QQuickItem *) override
void incubatorStateChanged(QQmlIncubator::Status status)
qreal getImplicitHeight() const override
void componentComplete() override
\reimp Derived classes should call the base class method before adding their own actions to perform a...
void itemChange(ItemChange change, const ItemChangeData &value) override
Called when change occurs for this item.
void resetSourceComponent()
void setSourceWithoutResolve(const QUrl &source)
void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override
QQuickLoader(QQuickItem *parent=nullptr)
\qmltype Loader \instantiates QQuickLoader \inqmlmodule QtQuick\inherits Item
Q_INVOKABLE void setSource(const QUrl &source, QJSValue initialProperties)
void asynchronousChanged()
void setSourceComponent(QQmlComponent *)
void setAsynchronous(bool a)
QQmlComponent * sourceComponent
void sourceComponentChanged()
void setActive(bool newVal)
\inmodule QtCore\reentrant
bool isValid() const
Returns true if the URL is non-empty and valid; otherwise returns false.
ReturnedValue value() const
void statusChanged(QQmlComponent::Status status)
[1]
Combined button and popup list for selecting options.
static const QCssKnownValue properties[NumProperties - 1]
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define Q_DECLARE_LOGGING_CATEGORY(name)
GLboolean GLboolean GLboolean GLboolean a
[7]
GLsizei GLsizei GLchar * source
GLdouble GLdouble GLdouble GLdouble q
QQmlEngine * qmlEngine(const QObject *obj)
QQmlContext * qmlContext(const QObject *obj)
void QQml_setParent_noEvent(QObject *object, QObject *parent)
Makes the object a child of parent.
QQuickItem * qmlobject_cast< QQuickItem * >(QObject *object)
Q_QML_EXPORT QQmlInfo qmlWarning(const QObject *me)
static QT_BEGIN_NAMESPACE const QQuickItemPrivate::ChangeTypes watchedChanges
QUrl url("example.com")
[constructor-url-reference]
QQmlRefPointer< QQmlContextData > callingQmlContext() const