diff --git a/src/controls/StackView.qml b/src/controls/StackView.qml index bd9c4de9c0ab4e7e88795c30e5348b915c6f4532..002355dc76b89a02539f22b17ebbdc3ac4b9e260 100644 --- a/src/controls/StackView.qml +++ b/src/controls/StackView.qml @@ -473,7 +473,7 @@ import QtQuick.Controls.Private 1.0 \endlist */ -Item { +FocusScope { id: root /*! \qmlproperty int StackView::depth diff --git a/tests/auto/controls/controls.pro b/tests/auto/controls/controls.pro index c3f0009414af94694c71e6a4746c43cf357bdb30..6ba1e3ea6fbe366278b35e472570bd2538fd4cb1 100644 --- a/tests/auto/controls/controls.pro +++ b/tests/auto/controls/controls.pro @@ -34,6 +34,8 @@ OTHER_FILES += \ $$PWD/data/tst_rowlayout.qml \ $$PWD/data/tst_gridlayout.qml \ $$PWD/data/tst_slider.qml \ + $$PWD/data/tst_stack.qml \ + $$PWD/data/tst_stackview.qml \ $$PWD/data/tst_statusbar.qml \ $$PWD/data/tst_switch.qml \ $$PWD/data/tst_tab.qml \ diff --git a/tests/auto/controls/data/tst_stackview.qml b/tests/auto/controls/data/tst_stackview.qml index 848be7258df1f8feb78f8fc92519b194b66f1658..f574feedf94d437dbe293a95a15b4c04b8cbbeaf 100644 --- a/tests/auto/controls/data/tst_stackview.qml +++ b/tests/auto/controls/data/tst_stackview.qml @@ -46,10 +46,12 @@ TestCase { id: testCase name: "Tests_StackView" when: windowShown + visible: true width: 400 height: 400 Item { id: anItem } + TextField { id: textField } Component { id: pageComponent Item {} @@ -57,7 +59,7 @@ TestCase { Component { id: stackComponent - StackView {} + StackView { anchors.fill: parent } } function test_stackview() { @@ -73,5 +75,27 @@ TestCase { verify (stack.depth === 1) stack.push(pageComponent) verify (stack.depth === 2) + stack.destroy() + } + + function test_focus() { + var stack = stackComponent.createObject(testCase, {initialItem: anItem}) + verify (stack !== null, "stackview created is null") + compare(stack.currentItem, anItem) + + stack.forceActiveFocus() + verify(stack.activeFocus) + + stack.push({item: textField, immediate: true}) + compare(stack.currentItem, textField) + textField.forceActiveFocus() + verify(textField.activeFocus) + + stack.pop({immediate: true}) + compare(stack.currentItem, anItem) + verify(stack.activeFocus) + verify(!textField.activeFocus) + + stack.destroy() } }