QObject *obj = incubator->object();
item = qobject_cast<QQuickItem*>(obj);
if (item) {
+ emit q->itemChanged();
initResize();
} else {
qmlInfo(q) << QQuickLoader::tr("Loader does not support loading non-visual elements.");
delete itemContext;
itemContext = 0;
delete obj;
+ emit q->itemChanged();
}
incubator->clear();
} else if (status == QDeclarativeIncubator::Error) {
itemContext = 0;
delete incubator->object();
source = QUrl();
+ emit q->itemChanged();
}
if (loadingFromSource)
emit q->sourceChanged();
emit q->sourceComponentChanged();
emit q->statusChanged();
emit q->progressChanged();
- emit q->itemChanged();
emit q->loaded();
disposeInitialPropertyValues(); // cleanup
}
--- /dev/null
+import QtQuick 2.0
+
+Item {
+ width: 200; height: 200
+
+ function switchComponent() {
+ load.sourceComponent = comp2
+ }
+
+ Component {
+ id: comp
+ Rectangle {
+ width: 50; height: 60; color: "red"
+ }
+ }
+
+ Component {
+ id: comp2
+ Rectangle {
+ width: 80; height: 90; color: "green"
+ }
+ }
+
+ Loader {
+ id: load
+ objectName: "loader"
+ sourceComponent: comp
+ height: item ? item.height : 0
+ }
+}
void asynchronous_clear();
void parented();
+ void sizeBound();
private:
QDeclarativeEngine engine;
delete root;
}
+void tst_QQuickLoader::sizeBound()
+{
+ QDeclarativeComponent component(&engine, testFileUrl("sizebound.qml"));
+ QQuickItem *root = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(root);
+ QQuickLoader *loader = root->findChild<QQuickLoader*>("loader");
+ QVERIFY(loader != 0);
+
+ QVERIFY(loader->item());
+
+ QCOMPARE(loader->width(), 50.0);
+ QCOMPARE(loader->height(), 60.0);
+
+ QMetaObject::invokeMethod(root, "switchComponent");
+
+ QCOMPARE(loader->width(), 80.0);
+ QCOMPARE(loader->height(), 90.0);
+
+ delete root;
+}
+
QTEST_MAIN(tst_QQuickLoader)