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

Focused QtQuick TableView.editDelegate receive information on keys

    XMLWordPrintable

Details

    • All

    Description

      Currently it’s not possible to get the pressed information of e.g. Return/Enter and Shift + Return/Enter keys when TableView.editDelegate has focus. The TableView::commit is emitted when Return or Enter is pressed and the editing finishes, but then no information of the Shift key can be obtained.

      Getting these events in some form would help e.g. to implement functionality, where the cell below the current one is focused after Enter key and the cell above after Shift+Enter.

      The following code snippet shows how with the current implementation the onAccepted, onEditingFinished and Keys.onReturnPressed are never triggered. The focus is set to the TextField for better UX.

          TableView {
              id: tableView
              ...
              editTriggers: TableView.AnyKeyPressed | TableView.DoubleTapped | TableView.SelectedTapped | TableView.EditKeyPressed
              delegate: Rectangle {
                  required property bool selected
                  required property bool current            implicitWidth: 100
                  implicitHeight: 20            Label {
                      id: displayLabel
                      anchors.centerIn: parent
                      text: model.display
                  }            TableView.editDelegate: TextField {
                      x: displayLabel.x
                      y: displayLabel.y
                      width: displayLabel.width
                      height: displayLabel.height
                      text: display                required property bool selected                Component.onCompleted: {
                          selectAll();
                          forceActiveFocus( Qt.MouseFocusReason );
                      }                TableView.onCommit: {
                          display = text
                          console.log("Editing finished, no key information", tableView.currentColumn, tableView.currentRow)
                      }                onAccepted: 
                          console.log("Accepted")
                      }                Keys.onReturnPressed: (event) => {
                          console.log("return", event.key)
                          event.accepted = false
                      }                onEditingFinished: {
                          console.log("Editing finished")
                      }
                  }
              }        selectionModel: ItemSelectionModel{}
          } 

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            tiheikka Titta Heikkala
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes