diff options
author | Alessandro Portale <alessandro.portale@qt.io> | 2017-08-03 20:04:57 +0200 |
---|---|---|
committer | Alessandro Portale <alessandro.portale@qt.io> | 2017-08-07 09:47:03 +0000 |
commit | 63f2f55462f2f040cfe175ada8aa1e01168597fc (patch) | |
tree | 3ec066df7cdc50d041afc3ba099cafd55153be71 | |
parent | a723ad813fbbaa3dc79f64c974fe011f805b2ef8 (diff) |
StackView: Resolve relative urls in initialItem
Check whether a URL is relative and try to resolve that.
Change-Id: I6b0f7bca2011356aca5071d20dbd270eb5d115bf
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r-- | src/quicktemplates2/qquickstackelement.cpp | 3 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_stackview.qml | 6 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/quicktemplates2/qquickstackelement.cpp b/src/quicktemplates2/qquickstackelement.cpp index a3bb840e..887d43af 100644 --- a/src/quicktemplates2/qquickstackelement.cpp +++ b/src/quicktemplates2/qquickstackelement.cpp @@ -130,6 +130,9 @@ QQuickStackElement *QQuickStackElement::fromString(const QString &str, QQuickSta return nullptr; } + if (url.isRelative()) + url = qmlContext(view)->resolvedUrl(url); + QQuickStackElement *element = new QQuickStackElement; element->component = new QQmlComponent(qmlEngine(view), url, view); element->ownComponent = true; diff --git a/tests/auto/controls/data/tst_stackview.qml b/tests/auto/controls/data/tst_stackview.qml index 0f73b631..1b421b4f 100644 --- a/tests/auto/controls/data/tst_stackview.qml +++ b/tests/auto/controls/data/tst_stackview.qml @@ -1123,6 +1123,12 @@ TestCase { compare(item1.StackView.visible, true) } + function test_resolveInitialItem() { + var control = createTemporaryObject(stackView, testCase, {initialItem: "TestItem.qml"}) + verify(control) + verify(control.currentItem) + } + function test_resolve() { var control = createTemporaryObject(stackView, testCase) verify(control) |