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

QTableView loses focus when tabbing in combination with custom editor which is a complex widget

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P3: Somewhat important
    • Some future release
    • 4.6.2
    • Widgets: Itemviews
    • None
    • Windows Vista

    Description

      suppose you use a complex widget (for example widget with 2 child widgets (QLineEdit and QPushButton) for editing a cell.
      When editing starts the focus is set on the complex widget.
      Typically this one will set the focus to it's first child (in this case the QLineEdit).
      If you then press TAB, focus should be set by your complex widget on to the second child: the QPushButton.
      If you then press TAB editing will stop and you expect to move to the next cell and focus should be on the QTableView.
      This does not happen.

      This is because in QAbstractItemView::closeEditor there is a check to see if the editor has the focus: editor->hasFocus().
      Only if this is the case setFocus() will be called on the QAbstractItemView.

      Because the QPushButton has the focus and not the 'top-level' widget, this doesn't happen and so focus is not set on the QTableView -> further keyboard navigation doesn't work...

      A solution would be to not just check if the editor has the focus, but also if one of its children has the focus.
      This could be achieved like this:

      bool hadFocus = editor->hasFocus() || editor->isAncestorOf(QApplication::focusWidget());

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            btanghe Bart Tanghe
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes