Results 1 to 2 of 2

Thread: Coordinate confusion

  1. #1
    Join Date
    Jan 2010
    Location
    Turkey
    Posts
    39
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Coordinate confusion

    I subclassed QGraphicsItem and reimplemented paint.
    In paint I wrote something like this for labeling the item:

    Qt Code:
    1. painter->drawText("Test",10,40);
    To copy to clipboard, switch view to plain text mode 

    After some time I think It may be useful to handle labeling with seperate item. So I wrote something like this.

    Qt Code:
    1. QGraphicsTextItem *label = new QGraphicsTextItem("TEST",this);
    2. setPos(10,40);
    To copy to clipboard, switch view to plain text mode 

    But two "TEST" drawing do not appear in the same place on screen. I guess difference may be related with item coordinates - scene coordinates. I tried all mapFrom... and mapTo... combinations inside QGraphicsItem interface but no progress. I want to drawings to appear in the same place on screen.
    What I miss?
    Last edited by onurozcelik; 14th June 2010 at 09:14. Reason: reformatted to look better

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Coordinate confusion

    try:
    Qt Code:
    1. QGraphicsTextItem *label = new QGraphicsTextItem("TEST",this);
    2. label->setPos(10,40);
    To copy to clipboard, switch view to plain text mode 
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. coordinate system
    By Wojtek.wk in forum Newbie
    Replies: 7
    Last Post: 12th April 2010, 13:47
  2. How to rotate qwt polar coordinate?
    By qmonkey in forum Qwt
    Replies: 5
    Last Post: 27th January 2010, 09:49
  3. coordinate problem
    By sai in forum Qt Programming
    Replies: 1
    Last Post: 17th April 2009, 10:21
  4. The coordinate system
    By avis_phoenix in forum Qt Programming
    Replies: 1
    Last Post: 28th July 2008, 12:16
  5. Replies: 22
    Last Post: 7th December 2007, 09:01

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.