Hi,

I am drawing a Pixmap in my paintEvent of my widget (shown below), I want to be able to basically be able to click the image and enlarge it and then click it again and shrink it back to normal size. The transforming stuff I got down, just trying to figure out how to create a click event for the QPixmap.

Any ideas?

Thanks.
Qt Code:
  1. void paintEvent(QPaintEvent *event) {
  2. QPainter painter(this);
  3.  
  4. // attempt of the new image and scale it graciously
  5. painter.setRenderHint(QPainter::Antialiasing);
  6. painter.setRenderHint(QPainter::SmoothPixmapTransform);
  7.  
  8. QPointF center(pixmap.width()/2.0, pixmap.height()/2.0);
  9.  
  10. painter.translate(center);
  11. painter.scale(m_scale, m_scale);
  12. painter.translate(-center);
  13.  
  14. if (m_scale == 1.0)
  15. painter.drawPixmap(5,22,pixmap.scaled(75,75, Qt::KeepAspectRatio));
  16. else
  17. painter.drawPixmap(QPointF(5, 22), pixmap);
  18.  
  19. QWidget::paintEvent(event);
  20. }
To copy to clipboard, switch view to plain text mode