PDA

View Full Version : Coordinates Related



jsmith
18th August 2009, 16:37
Hi,
i have widget of(600*600). I have implemented paintEvent() and wheel event for zoom
as

wheelEvent(QWheelEvent*)
{
if(event->.. >0)
{
scale+=0.5;
translate_x +=600/4;
translate_y +=600/4;
}
if(event->..<0)
{
scale-=0.5;
translate_x -=600/4;
translate_y -=600/4;

}
}

paintEvent(QPaintEvent*)
{
QPainter painter;
painter.Begin(this);
painter.translate(-translate_x,translate_y);
painter.scale(scale,scale);
painter.drawpixmap(0,0,600,600,QPixmap("/images/im.jpg"));
painter.end();}

}

in mouse move event i have written code such a way that it showa x,and y values on status bar. now my problem is it is showing correctly when scale is 1. but when it is zoomin also it is showing same x,y values i.e x - from 0 to 600 and y also same. Please help me when pixmap is zoom in x,y values will change. how to calculate this ?
Thanks in advance