PDA

View Full Version : Coordinate confusion



onurozcelik
14th June 2010, 09:13
I subclassed QGraphicsItem and reimplemented paint.
In paint I wrote something like this for labeling the item:


painter->drawText("Test",10,40);

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


QGraphicsTextItem *label = new QGraphicsTextItem("TEST",this);
setPos(10,40);

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?

high_flyer
14th June 2010, 09:42
try:


QGraphicsTextItem *label = new QGraphicsTextItem("TEST",this);
label->setPos(10,40);