diff options
author | Martin Jones <martin.jones@nokia.com> | 2012-03-30 10:48:50 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-30 07:40:32 +0200 |
commit | 2ab873ed5fbb43404f119ef05b412485665a975f (patch) | |
tree | e66167b3e2d8712f96931734b1c7c62842c283f7 /tests/auto/quick/qquickloader | |
parent | ab45c8da80968c4fabdb121c7eea48164d2216ff (diff) |
Size loaded item before bindings are evaluated
If the Loader size is set explicitly we can set the item size
before the bindings are run, and avoiding an additional
anchor layout.
Also ensure item implict size changes are propagated/notified in the
Loader.
Change-Id: Ie22b018b22be8457ccf30b907a26e44260b9cef7
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Diffstat (limited to 'tests/auto/quick/qquickloader')
-rw-r--r-- | tests/auto/quick/qquickloader/data/implicitSize.qml | 5 | ||||
-rw-r--r-- | tests/auto/quick/qquickloader/tst_qquickloader.cpp | 12 |
2 files changed, 17 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickloader/data/implicitSize.qml b/tests/auto/quick/qquickloader/data/implicitSize.qml index 5c8c8348ed..ae8c0b8b30 100644 --- a/tests/auto/quick/qquickloader/data/implicitSize.qml +++ b/tests/auto/quick/qquickloader/data/implicitSize.qml @@ -3,12 +3,17 @@ import QtQuick 2.0 Rectangle { property real implWidth: 0 property real implHeight: 0 + function changeImplicitSize () { + loader.item.implicitWidth = 200 + loader.item.implicitHeight = 300 + } color: "green" width: loader.implicitWidth+50 height: loader.implicitHeight+50 Loader { id: loader + objectName: "loader" sourceComponent: Item { anchors.centerIn: parent diff --git a/tests/auto/quick/qquickloader/tst_qquickloader.cpp b/tests/auto/quick/qquickloader/tst_qquickloader.cpp index 01781f7b54..ea35897004 100644 --- a/tests/auto/quick/qquickloader/tst_qquickloader.cpp +++ b/tests/auto/quick/qquickloader/tst_qquickloader.cpp @@ -842,6 +842,18 @@ void tst_QQuickLoader::implicitSize() QCOMPARE(item->property("implHeight").toReal(), 100.); QCOMPARE(item->property("implWidth").toReal(), 100.); + QQuickLoader *loader = item->findChild<QQuickLoader*>("loader"); + QSignalSpy implWidthSpy(loader, SIGNAL(implicitWidthChanged())); + QSignalSpy implHeightSpy(loader, SIGNAL(implicitHeightChanged())); + + QMetaObject::invokeMethod(item, "changeImplicitSize"); + + QCOMPARE(loader->property("implicitWidth").toReal(), 200.); + QCOMPARE(loader->property("implicitHeight").toReal(), 300.); + + QCOMPARE(implWidthSpy.count(), 1); + QCOMPARE(implHeightSpy.count(), 1); + delete item; } |