Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Why is QGraphicsScene::focusItem() looking at isActive() and not hasFocus() to return the passive item.



  • I am trying to understand why QGraphicsItem::focusItem() is implemented by going to the focused item if it is active, and the passive focus item if it is not active. The passive focus item is set in situation like clearFocus(), which sets the hasFocus() flag, so why shouldn't focusItem() use that same flag instead of looking if the scene is active.

    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. Should it return the passive focus item in that situation, where the scene is active, but it does not have focus?



  • Since I didn't get any feedback, I opted to file a bug as I am fairly sure this behaviour is incorrect:
    https://bugreports.qt.io/browse/QTBUG-85728


Log in to reply