Results 1 to 3 of 3

Thread: return of absolute coordinates in svg-graphics

  1. #1
    Join Date
    Feb 2006
    Location
    Magdeburg
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default return of absolute coordinates in svg-graphics

    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:os() 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

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: return of absolute coordinates in svg-graphics

    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:
    Qt Code:
    1. QPoint picturePos = widget()->mapFromParent(event->pos());
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Feb 2006
    Location
    Magdeburg
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: return of absolute coordinates in svg-graphics

    thx

    sounds good. I will try that

Similar Threads

  1. Absolute widget coordinates
    By rbp in forum Qt Programming
    Replies: 4
    Last Post: 28th January 2009, 04:30
  2. error with QList with a class
    By john_god in forum Newbie
    Replies: 7
    Last Post: 12th January 2009, 21:48
  3. QTableView performances
    By miraks in forum Qt Programming
    Replies: 18
    Last Post: 1st December 2008, 10:25
  4. Replies: 4
    Last Post: 5th August 2008, 19:55
  5. QTableView Repaint/Refresh
    By millsks in forum Newbie
    Replies: 9
    Last Post: 10th January 2008, 17:18

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.