Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.14.2
Description
I want to skip a SpinBox in the tab focus chain if it is not editable, but I noticed that it is always included in the tab focus chain, despite setting it's focusPolicy.
I found that in this case, activeFocusItem is of type QQuickTextInput, so it seems that the focus is still given to it's TextInput
Edit: I made a simple example showing the issue. See below and/or attachment.
I also added a gif where I use tab to demo the next in chain focus (and clicked some buttons to show their focusPolicy-usage)
// Main.qml import QtQuick 2.14 import QtQuick.Window 2.14 import QtQuick.Layouts 1.14 import QtQuick.Controls 2.14 Window { id: mainWindow width: 640 height: 480 visible: true title: qsTr("Hello World") function getFocusPolicy(intValue) { switch (intValue) { case Qt.TabFocus: return "TabFocus"; case Qt.ClickFocus: return "ClickFocus"; case Qt.StrongFocus: return "StrongFocus"; case Qt.WheelFocus: return "WheelFocus"; case Qt.NoFocus: return "NoFocus"; } } ColumnLayout { TestSpinBox {} TestButton { } TestSpinBox { focusPolicy: Qt.StrongFocus } TestButton { focusPolicy: Qt.StrongFocus } TestSpinBox { focusPolicy: Qt.ClickFocus } TestButton { focusPolicy: Qt.ClickFocus } TestSpinBox { focusPolicy: Qt.TabFocus } TestButton { focusPolicy: Qt.TabFocus } TestSpinBox { focusPolicy: Qt.NoFocus } TestButton { focusPolicy: Qt.NoFocus } } }
// TestButton.qml import QtQuick 2.14 import QtQuick.Controls 2.14 Button { id: testButton implicitHeight: 24 implicitWidth: 120 background: Rectangle { color: testButton.activeFocus ? "green" : "grey" } text: mainWindow.getFocusPolicy(testButton.focusPolicy) }
// TestSpinBox import QtQuick 2.14 import QtQuick.Layouts 1.14 import QtQuick.Controls 2.14 RowLayout { id: testSpinBox property int focusPolicy: 0 Text { text: mainWindow.getFocusPolicy(spinBox.focusPolicy) } SpinBox { id: spinBox; focusPolicy: testSpinBox.focusPolicy } }
Attachments
Issue Links
- relates to
-
QTBUG-80648 SpinBox does not lose focus
- Open