rishid
22nd February 2008, 15:49
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.
void paintEvent(QPaintEvent *event) {
QPainter painter(this);
// attempt of the new image and scale it graciously
painter.setRenderHint(QPainter::Antialiasing);
painter.setRenderHint(QPainter::SmoothPixmapTransf orm);
QPointF center(pixmap.width()/2.0, pixmap.height()/2.0);
painter.translate(center);
painter.scale(m_scale, m_scale);
painter.translate(-center);
if (m_scale == 1.0)
painter.drawPixmap(5,22,pixmap.scaled(75,75, Qt::KeepAspectRatio));
else
painter.drawPixmap(QPointF(5, 22), pixmap);
QWidget::paintEvent(event);
}
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.
void paintEvent(QPaintEvent *event) {
QPainter painter(this);
// attempt of the new image and scale it graciously
painter.setRenderHint(QPainter::Antialiasing);
painter.setRenderHint(QPainter::SmoothPixmapTransf orm);
QPointF center(pixmap.width()/2.0, pixmap.height()/2.0);
painter.translate(center);
painter.scale(m_scale, m_scale);
painter.translate(-center);
if (m_scale == 1.0)
painter.drawPixmap(5,22,pixmap.scaled(75,75, Qt::KeepAspectRatio));
else
painter.drawPixmap(QPointF(5, 22), pixmap);
QWidget::paintEvent(event);
}