PDA

View Full Version : itemChange method



zgulser
17th August 2009, 07:30
Hi,

I have a very trivial question.I'm getting some sort of odd values from the newPos.x() & newPos.y() values in itemChange method. The odd about it is the item's position is not returned in scene coordinates...Do you have any idea?

wagmare
17th August 2009, 07:52
QGraphicsItem::itemChange .. it will return only in item coordinates ...
ex:
QTDIR/demos/embeddeddialogs/customproxy.cpp

use
QPolygonF QGraphicsItem::mapToScene ( const QRectF & rect ) const

to map the coordinates to scene ...

zgulser
17th August 2009, 08:49
Hımm..thanks for your answer.

By the way, what about the QGraphicsItem::contains(QPointF point) method? I mean does the point searched in the item's local coordinates? In the documentation, it says "local coordinates". Does it mean item's coordinate system? More clearly, what the mechanism behind the QGraphicsItem::contains(QPointF point) method?

Thanks in advance.

wagmare
17th August 2009, 09:04
it says "local coordinates". Does it mean item's coordinate system?

absolutly .... from docs it says ..

Items live in their own local coordinate system

QGrahpicsItem::contains()
takes a point argument in item coordinates only ...

The Graphics View Framework will explain u clearly than me ..

zgulser
17th August 2009, 09:19
Ok buddy, thanks again.

Oh, I'm about to forget to ask...If the item coordinate system is taken into account in contains method, how do I make sure that the given point to be searched will be mapped to item coordinate system. Do I really need to worry about that or QGraphicsView framework does the transformation automatically?