0

I programmatically move the items in my QGraphicsScene and they end up in the wrong places. They end up at coordinates (2x, 2y), instead of (x, y).

Somewhere I am changing the wrong thing. I work both with the scene and with individual items, accessing both through pointers.

QGraphicsItem::pos() can give you the position in scene coordinates (it has no parent). QGraphicsScene holds a list of all the items within the scene: QList<QGraphicsItem *> QGraphicsScene::items () const.

My question: the information of where an item is on the scene - is it stored within the scene or within the item?

Thanks!

Angie Quijano
  • 4,167
  • 3
  • 25
  • 30
AJO_
  • 315
  • 1
  • 2
  • 10

1 Answers1

0

In item i.e. in qgraphicsitem pimpl class. Open qgraphicsitem_p.h and there you will find QPointF pos member.

nomenas
  • 111
  • 3
  • Thank you, nomenas. I did find a QPointF pos member in qgraphicsitem_p.h. Should the scene coordinates change ... all items within the scene would have to have these values updated, I guess. – AJO_ Nov 15 '12 at 06:45
  • In furtherance of this, I found that QGraphicsScene bases its item index on QGraphicsItem::boundingRect() (it's actually virtual). I presume the item index is useful for finding items. – AJO_ Nov 16 '12 at 08:20