Results 1 to 2 of 2

Thread: QGraphicsView Framework coordinate mapping problem

  1. #1
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default QGraphicsView Framework coordinate mapping problem

    Hi,

    I have an item which resides in an item group. Note that I did;

    Qt Code:
    1. setHandlesChildEvents(TRUE)
    To copy to clipboard, switch view to plain text mode 
    .

    When I move my item by the cursor(drag-drop), I want to see, update and maintain it's position. But here are the problems...

    1. When I print out the item's position in item group like ;

    Qt Code:
    1. cout<<"Position of item , x-coordinate: "<<item->pos().x()<<endl;
    2. cout<<"Position of item , y-coordinate: "<<item->pos().y()<<endl
    To copy to clipboard, switch view to plain text mode 

    it gives me a pair of (0,0). Isn't that odd?

    2. When I print out the item group's coordinates like;

    Qt Code:
    1. cout<<"Position of item , x-coordinate: "<<pos().x()<<endl;
    2. cout<<"Position of item , y-coordinate: "<<pos().y()<<endl
    To copy to clipboard, switch view to plain text mode 

    it gives me the values in local coordinates. How can I convert these to scene coordinates? mapToScene(pos()) gives the same result by the way!

  2. #2
    Join Date
    Sep 2009
    Posts
    140
    Thanks
    4
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsView Framework coordinate mapping problem

    Hard to answer without knowing where you display the coordinates values.
    For instance, in item change, you can get coordinates before modification.

    Since coordinates of an item are relative to its parent, it may be normal to have (0,0) if it is a child item, as part of the group.

    You might try to combine mapFromScene and mapFromParent to control extacly the reference coordinates system : scene, group, item?


    S.Cascio

Similar Threads

  1. Qt Coordinate System and the Graphics View Framework
    By djurodrljaca in forum Qt Programming
    Replies: 14
    Last Post: 17th February 2012, 11:19
  2. Problem determining size of QGraphicsView
    By Bocki in forum Qt Programming
    Replies: 3
    Last Post: 17th February 2008, 14:54
  3. Smooth pixmap transform in QGraphicsView problem
    By spud in forum Qt Programming
    Replies: 1
    Last Post: 24th October 2007, 16:47
  4. QGraphicsView scrolling problem with 4.3.0
    By hb in forum Qt Programming
    Replies: 8
    Last Post: 30th August 2007, 22:18
  5. Problem with QGraphicsView.
    By kiranraj in forum Qt Programming
    Replies: 1
    Last Post: 4th July 2007, 19:44

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.