Details
-
Bug
-
Resolution: Out of scope
-
P4: Low
-
None
-
4.7.2
-
None
Description
While investigating QTBUG-14716 I noticed that invisible items can gain focus in QGraphicsItem::setFocusHelper but cannot gain focus in QGraphicsScene::setFocusItemHelper. This means that trying to set focus on an invisible item leads to the situation where the item believes that it has focus but the scene does not think there is a focused item (so key events go nowhere). A simple patch to rectify the inconsistency is attached, but it's possible that the problem is not in setting subFocus internally but in returning the item in QGraphicsItem::focusItem() despite not being visible. (also, in this instance the item doesn't gain focus when it becomes visible, somewhat inconsistent with the setFocus docs).
This problem can be seen in the Samegame demo (only within qtdemo, presumably due to the extra focus scope) before the commit that fixes QTBUG-14716 (which works around this problem by only setting focus once the TextInput is visible). QDeclarativeItem::activeFocus is true on the TextInput because focusItem() called on the object says that it has focus, but the scene focus item is null (leading to no key events being delivered).