Details
-
Bug
-
Resolution: Duplicate
-
P3: Somewhat important
-
4.6.0, 4.6.1, 4.6.2
Description
When QGraphicsView widget will be add in QStackedLayout, scene presented by that view is deactivated and after user is not able to set focus on contained graphics widget. As result of this user is not able to modify graphics items.
Here is brief analysis of the problem:
1. QStackedLayout::insertWidget method calls widget->hide() method and with that QEvent::Hide is emitted
2. QEvent::Hide event is handled by QGraphicsView::viewportEvent method and it emits QEvent::WindowDeactivate event.
3. QEvent::WindowDeactivate is handled by QGraphicsScene::event(QEvent *event) and this method decrements activationRefCount counter (in this case activationRefCount = -1).
4. When graphics view widget will be shown in the stacked view activationRefCount will be increment and it will be equal to 0, although it is active
...
n. User is not able to edit scene graphics items because they can not get focus (QGraphicsScene::isActive() returns false because activationRefCount == 0)
I suggest QGraphicsScene::event(QEvent *event) to be modified in the following manner:
case QEvent::WindowDeactivate: if (!d->activationRefCount) { if (d->activePanel) { // Deactivate the active panel (but keep it so we can // reactivate it later). QGraphicsItem *lastActivePanel = d->activePanel; ... } --d->activationRefCount; }