Results 1 to 4 of 4

Thread: Why does QGraphicsItem::scenePos() return (0,0)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2009
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Why does QGraphicsItem::scenePos() return (0,0)

    Hi all,

    I am trying to implement a drawing canvas with QGraphicsView and QGraphicsScene. What is perplexing is that after I add a new item to the scene, it's scenePos() is always (0,0). As a trial I test out the following code:

    Qt Code:
    1. QGraphicsLineItem * anotherLine = this->addLine(50,50, 100, 100);
    2. qDebug() << anotherLine->scenePos();
    3.  
    4. QGraphicsLineItem * anotherLine2 = this->addLine(80,10, 300, 300);
    5. qDebug() << anotherLine2->scenePos();
    To copy to clipboard, switch view to plain text mode 
    Where the this pointer is a class derived from QGraphicsScene. The output for both line is QPointF(0,0).

    To my understanding, scenePos() should be returning the position of the QGraphicsItem within the scene itself, but right now it is acting as if it is returning the origin of the item within its own local coordinate. What am I doing wrong?
    Last edited by extrakun; 20th July 2009 at 06:41. Reason: missing [code] tags

Similar Threads

  1. error with QList with a class
    By john_god in forum Newbie
    Replies: 7
    Last Post: 12th January 2009, 21:48
  2. Once more : QAbstractItemModel woes
    By Valheru in forum Qt Programming
    Replies: 10
    Last Post: 15th January 2008, 10:44
  3. QTableView Repaint/Refresh
    By millsks in forum Newbie
    Replies: 9
    Last Post: 10th January 2008, 17:18
  4. Qt Cryptographic Architecture
    By vermarajeev in forum Qt Programming
    Replies: 6
    Last Post: 9th February 2007, 13:15
  5. Version 4.1.3 and QTreeView
    By greencastor in forum Qt Programming
    Replies: 2
    Last Post: 13th June 2006, 10:37

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.