I need to draw a circle within a QPixmap, where the radius of the circle is slightly too big to fit inside the pixmap. The following code draws the circle nicely enough (with a cross and a square as well for good measure):

Qt Code:
  1. painter.setViewport(m_originX, m_originY, m_sideX, m_sideY);
  2. painter.setWindow(0, 0, m_pixmap.width(), m_pixmap.height());
  3.  
  4. painter.drawPixmap(0, 0, m_pixmap);
  5.  
  6. painter.drawLine(centre.x() - 20, centre.y(), centre.x() + 20, centre.y());
  7. painter.drawLine(centre.x(), centre.y() - 20, centre.x(), centre.y() + 20);
  8. painter.drawRect(centre.x(), centre.y(), squareSize, squareSize);
  9. painter.drawEllipse(centre.x(), centre.y(), circleSize, circleSize););
To copy to clipboard, switch view to plain text mode 

Capture.JPG

...except that the parts of the circle outside the QPixmap are also drawn. What I'd really like is to draw only the parts of the circle that lie within the QPixmap, so no lines are visible outside of the image.

Can this be done?