Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-8188

QGraphicsScene: Scene is not active after adding of scene view into a QStackedLayout

    XMLWordPrintable

Details

    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;
               }
      

      Attachments

        1. qgraphicsscene.patch
          0.8 kB
          Naum Puroski
        2. QtBug8188.rar
          9 kB
          Naum Puroski

        Activity

          People

            ylopes Yoann Lopes
            nomenas Naum Puroski
            Votes:
            3 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: