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());
679 qCDebug(lcTransient) <<
window <<
"is transient for" <<
q->window();
680 window->setTransientParent(
q->window());
683 emit q->itemChanged();
693 emit q->itemChanged();
696 emit q->sourceChanged();
698 emit q->sourceComponentChanged();
700 emit q->progressChanged();
712 emit q->sourceChanged();
714 emit q->sourceComponentChanged();
716 emit q->progressChanged();
717 emit q->itemChanged();
726 if (!creationContext)
732 return creationContext;
791 return static_cast<Status>(
d->status);
799 if (
d->loadingFromSource)
800 d->createComponent();
810 qCDebug(lcTransient) << loadedWindow <<
"is transient for" <<
value.window;
811 loadedWindow->setTransientParent(
value.window);
842 return d->component->progress();
883 return d->asynchronous;
889 if (
d->asynchronous ==
a)
895 if (
d->loadingFromSource &&
d->component &&
d->component->isLoading()) {
897 QUrl currentSource =
d->source;
899 d->source = currentSource;
901 }
else if (
d->incubator &&
d->incubator->isLoading()) {
902 d->incubator->forceCompletion();
915 const bool needToUpdateWidth = loaderGeometryChanged &&
q->widthValid();
916 const bool needToUpdateHeight = loaderGeometryChanged &&
q->heightValid();
918 if (needToUpdateWidth && needToUpdateHeight)
920 else if (needToUpdateWidth)
922 else if (needToUpdateHeight)
950 if (newGeometry != oldGeometry) {
995 if (
status != newStatus) {
997 emit q->statusChanged();
1015 qmlWarning(
q) <<
"createComponent: Cannot find a QML engine.";
1020#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.
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
void clearContextRecursively()
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 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)
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
\inmodule QtCore\reentrant
bool isValid() const
Returns true if the URL is non-empty and valid; otherwise returns false.
ReturnedValue value() const
void statusChanged(QDeclarativeComponent::Status status)
[1]
Combined button and popup list for selecting options.
static const QCssKnownValue properties[NumProperties - 1]
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define qCDebug(category,...)
#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
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent