PDA

View Full Version : return of absolute coordinates in svg-graphics



hulk
22nd February 2006, 10:01
Hello all.


Qt 4.1.0 is able to display svg-graphics. There is an example included: "Qt\4.1.0\examples\painting\svgviewer". I am trying to change this program a little bit.

This viewer can load svg-graphics. With the help of the mousewheel it is possible to zoom. Scrollbars will appear, if the zoomed picture is to big.

My Problem: I want to write a function which enables me to point with the mouse on any position on the picture and the absolute/real position ON THE PICTURE ist returned. QMouseEvent::pos() and QMouseEvent::globalPos() only return the relative position of the pointer in the window.

How can I get the absolute position?

Thanks for any answers, Hagen


PS: sorry for my probably bad english

jpn
22nd February 2006, 10:39
You can get the actual picture position by mapping the event's position (which is relative to the scroll area) from the widget's (inside the scroll area) point of view.

So eg. in SvgWindow::mouseMoveEvent() you could have something like:


QPoint picturePos = widget()->mapFromParent(event->pos());

hulk
22nd February 2006, 13:23
thx

sounds good. I will try that