Results 1 to 4 of 4

Thread: How to efficiently get position of a QGraphicsItem in view coordinates?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Jan 2012
    Posts
    66
    Platforms
    Windows
    Thanks
    20
    Thanked 2 Times in 2 Posts

    Default Re: How to efficiently get position of a QGraphicsItem in view coordinates?

    Oh ok. Just so I understand you correctly, QGraphicsView::mapFromScene just returns a coordinate, it doesn't actually have to "map" it first? I had a look at the source and it looks like it is being mapped, though I could be wrong:

    Qt Code:
    1. QPoint QGraphicsView::mapFromScene(const QPointF &point) const
    2. {
    3. Q_D(const QGraphicsView);
    4. QPointF p = d->identityMatrix ? point : d->matrix.map(point);
    5. p.rx() -= d->horizontalScroll();
    6. p.ry() -= d->verticalScroll();
    7. return p.toPoint();
    8. }
    To copy to clipboard, switch view to plain text mode 

    EDIT: I realized I misunderstood you. So it does map it, and that's the most direct way. Bummer. Well, thanks for letting me know.
    Last edited by wayfaerer; 8th February 2012 at 01:54.

Similar Threads

  1. QGraphicsItem coordinates, again
    By d_stranz in forum Qt Programming
    Replies: 15
    Last Post: 20th June 2011, 21:10
  2. Replies: 7
    Last Post: 21st March 2010, 03:11
  3. Replies: 0
    Last Post: 24th November 2008, 08:52
  4. Working with coordinates (QGraphicsScene/view)
    By maverick_pol in forum Qt Programming
    Replies: 5
    Last Post: 27th March 2008, 08:35
  5. Replies: 1
    Last Post: 26th September 2006, 05:38

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.