title: Qt - circles for collision detection
body: <p>I've been working on a physics simulation with circles in Qt. Thus far the easiest way to define circles I found is to make a <code>QRect</code> object and then draw the ellipse with that rectangle as a "blueprint". Now I've just got the problem that it paints a circle but the hit box for the hit detection is still a square, which looks rather awkward. I've not been able to find a solution for it thus far and hope to find some help here.</p>
  
  <pre><code>QRectF Ball::boundingRect() const
  {    
    return QRect(0,0,20,20);
  }
  void Ball::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
  {
      QRectF rec = boundingRect();
      QBrush Brush(Qt::gray);
  
      //basic Collision Detection
  
      if(scene()-&gt;collidingItems(this).isEmpty())
      {
          //no collision
          Brush.setColor(Qt::green);
      }
      else
      {
          //collision!!!!!
          Brush.setColor(Qt::red);
  
          //Set position
          DoCollision();
      }
  
      //painter-&gt;fillEllipse(rec,Brush);
      painter-&gt;drawEllipse(rec);
  }
  </code></pre>