Details
-
Bug
-
Resolution: Out of scope
-
P3: Somewhat important
-
4.6.2
-
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());