title: QGraphicsPixmapItem - trigger only event of the top object
body: <p>I am trying to make a card game. The player has vector of Cards and(hand) which is represtend in GUI. </p>
  
  <p><a href="https://i.stack.imgur.com/Klj9q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Klj9q.png" alt="Example how it looks"></a></p>
  
  <p>My cards inherits from QGraphicsPixmapItem and QObject.
  What I want to achieve is to set MouseEvent on Card and trigger this event only for one single card. Now there is a problem if I click on Card, there are situation whey ther are close(like in the picture) and event occurs on more than one card.</p>
  
  <p>How can I preventing my Cards from this behaviour?</p>
  
  <p>Here's my Card.cpp (with sceneEvent method)</p>
  
  <pre><code>#include "Card.h"
  #include "Game.h"
  #include &lt;string&gt;
  #include &lt;QDebug&gt;
  #include &lt;QPixmap&gt;
  #include &lt;QSize&gt;
  #include &lt;QKeyEvent&gt;
  #include &lt;QMouseEvent&gt;
  #include &lt;QEvent&gt;
  
  extern Game * game;
  
  Card::Card(QString pixmapURL, std::string rank, std::string suit, int value)
  {
      this-&gt;pixmapURL = pixmapURL;
      this-&gt;rank = rank;
      this-&gt;suit = suit;
      this-&gt;value = value;
  
      setPixmap(QPixmap(this-&gt;pixmapURL));
      setScale(0.10);
  }
  
  int Card::getValue()
  {
      return this-&gt;value;
  }
  
  std::string Card::getSuit()
  {
      return this-&gt;suit;
  }
  
  std::string Card::getRank()
  {
      return this-&gt;rank;
  }
  
  void Card::display()
  {
      qDebug() &lt;&lt; this-&gt;suit.c_str() &lt;&lt; this-&gt;rank.c_str();
  }
  
  bool Card::sceneEvent(QEvent *event)
  {
      if (event-&gt;type() == QEvent::GraphicsSceneMousePress) {
          //qDebug() &lt;&lt; event-&gt;MouseButtonPress;
          setPos(game-&gt;scene-&gt;width()/2, game-&gt;scene-&gt;height()/2);
      }
      return QGraphicsItem::sceneEvent(event);
  }
  </code></pre>