summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview/qgraphicsitem.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/graphicsview/qgraphicsitem.cpp')
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index f7075e9..b4b302a 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -3349,6 +3349,12 @@ void QGraphicsItem::clearFocus()
*/
void QGraphicsItemPrivate::clearFocusHelper(bool giveFocusToParent)
{
+ QGraphicsItem *subFocusItem = q_ptr;
+ if (flags & QGraphicsItem::ItemIsFocusScope) {
+ while (subFocusItem->d_ptr->focusScopeItem)
+ subFocusItem = subFocusItem->d_ptr->focusScopeItem;
+ }
+
if (giveFocusToParent) {
// Pass focus to the closest parent focus scope
if (!inDestructor) {
@@ -3357,10 +3363,10 @@ void QGraphicsItemPrivate::clearFocusHelper(bool giveFocusToParent)
if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
if (p->d_ptr->focusScopeItem == q_ptr) {
p->d_ptr->focusScopeItem = 0;
- if (!q_ptr->hasFocus()) //if it has focus, focusScopeItemChange is called elsewhere
+ if (!subFocusItem->hasFocus()) //if it has focus, focusScopeItemChange is called elsewhere
focusScopeItemChange(false);
}
- if (q_ptr->hasFocus())
+ if (subFocusItem->hasFocus())
p->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ false,
/* focusFromHide = */ false);
return;
@@ -3370,7 +3376,7 @@ void QGraphicsItemPrivate::clearFocusHelper(bool giveFocusToParent)
}
}
- if (q_ptr->hasFocus()) {
+ if (subFocusItem->hasFocus()) {
// Invisible items with focus must explicitly clear subfocus.
clearSubFocus(q_ptr);