Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-61348

ComboBox's highlight should be updated when currentIndex is changed

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Done
    • P3: Somewhat important
    • 5.11.0 Beta 2
    • None
    • Quick: Controls 2
    • 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

        1. combobox-find.gif
          21 kB
          Mitch Curtis
        For Gerrit Dashboard: QTBUG-61348
        # Subject Branch Project Status CR V

        Activity

          People

            Unassigned Unassigned
            mitch_curtis Mitch Curtis
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes