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

Adding Custom QGraphicsItem to QGraphicsItemGroup - Mouse Events not propagated to item

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • Some future release
    • 4.7.0, 4.7.1, 5.4.2
    • Widgets: GraphicsView
    • None

    Description

      When adding a custom overrided QGraphicsItem to a QGraphicsItemGroup, the item's mousePressEvent(QGraphicsSceneMouseEvent *event) and void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) are not being executed. The QGraphicsScene is not propagating the event to the item. If the item is added to the scene it works but obviously the item is not treated as a group anymore. Note: I am currently using QT4.4.1 and this problem does not occur. I tried QT4.70 and QT4.71 and both exhibit this problem. I am in the processing of transistioning from QT4.4.1 to QT4.7X and I noticed this problem.
      Reproduce this with the attached source , add the item to the group, then add the group to the scene, then you will not see the debug mousepressevent() mousereleaseevent() in the Item. ( The View is receiving the mouse event and same with the scene, the scene is sending the event to the item but item is not receiving the event)
      Please suggest a workaround if possible. My previous Qt4.4.1 version is commercial edition.

      *EDIT*
      Adding this to the item seems to work OK
      bool GraphicsItem::sceneEvent(QEvent *event)
      {
      if (event->type() == QEvent::GraphicsSceneMousePress)

      { mousePressEvent(static_cast<QGraphicsSceneMouseEvent *>(event)); }

      else if (event->type() == QEvent::GraphicsSceneMouseRelease)

      { mouseReleaseEvent(static_cast<QGraphicsSceneMouseEvent *>(event)); }

      event->setAccepted(true);
      return true;
      }

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            qbelcort Cory Bellamy
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes