Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.15.0
-
None
Description
I have a Windows application that has a QGraphicsView as its only main view. From what I can tell, the scene is only inactive when the application itself is not active. When clicking into another widget, the scene loses focus, and I have no way to get at the item that had focus, because QGraphicsScene::focusItem() returns NULL, yet the passive focus item is set to the item I would like to have.
The QGraphicsScene has the following documentation:
If the scene loses focus, (i.e.,
someone calls clearFocus()) while an item has focus, the scene will
maintain its item focus information, and once the scene regains focus, it
will make sure the last focus item regains focus.
It maintains that focused item via its passiveFocusItem member when the scene loses focus, for example, via a clearFocus() call.
However QGraphicsScene::focusItem() only returns the focusItem member if the scene is active, and returns the passiveFocusItem member if the scene is not active. I believe that it should instead return the focusItem member if the scene has focus, and return the passiveFocusItem member if the scene does not have focus. In other words, I believe the isActive() call in QGraphicsScene::focusItem() should be changed to an hasFocus() call.