Details
-
Suggestion
-
Resolution: Done
-
P3: Somewhat important
-
None
-
None
-
79964673d1587f9e6a254cb6a1f0dd0645b946e6
Description
I'm after a way to select items with the keyboard (after the combo box popup has been opened with the mouse) without giving the combo box a keyboard-based focus policy. The example below works, but there is no visual feedback that the current item has changed when a key is pressed; it only becomes obvious once the combo box popup is closed.
import QtQuick 2.6 import QtQuick.Controls 2.1 ApplicationWindow { visible: true width: 640 height: 480 ComboBox { id: comboBox model: ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L"] focusPolicy: Qt.ClickFocus anchors.centerIn: parent Keys.onPressed: { if (event.key >= Qt.Key_A && event.key <= Qt.Key_Z) { var index = comboBox.find(event.text, Qt.MatchStartsWith); print(index) if (index !== -1) { comboBox.currentIndex = index; event.accepted = true; } } } } }
Attachments
For Gerrit Dashboard: QTBUG-61348 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
222868,5 | ComboBox: fix key search in the popup | 5.11 | qt/qtquickcontrols2 | Status: MERGED | +2 | 0 |