Hi,
it is a little confusing but I get it now :). Thank You.
Dawid
> Dawid Sip wrote:
>> Hi,
>> Im still doing my Polygon Path and I came across a following problem,
>> I'm guessing this could be a bug. Inside of MyGraphicsView class i
>> create a MyPolygon instance. MyPolygon class has an inner class
>> definition of MyGraphicsEllipseItem which I use to visualize control
>> points (vertices of the polygon). Now, when I press a mouse button
>> over such ellipse the mousePressEvent is called and in this method I
>> want to retrieve this ellipse item's position and print it in the
>> console ->System.out.println("X "+this.scenePos().x()+" Y
>> "+this.scenePos().y());. Unfortunately i allways get X 0 Y 0 although
>> ellipses are placed in different positions then (0,0) in the scene. I
>> think I tryed everything by now. I can easily overcome this problem
>> by adding the position variable to the MyGraphicsEllipseItem where I
>> keep the postion but I don't like to waste resources so if You could
>> please explain why this doesn't work, I would be thankfull.
>
> Hi Dawid,
>
> This is not so much a bug, as it is a very common misconception ;-)
> The graphics items have a geometry and an anchoring position. The
> geometry is the shape of the item, in this case an ellipse located at:
>
>> new MyGraphicsEllipseItem(pos.x()-8, pos.y()-8, 15, 15, this.parent,
>
> The thing to realize is that this position is relative to the items
> coordinate system. The shape and position of the items coordinate
> system is set by its position, accessible via pos() or scenePos()
> depending on relative to what you want, and its transformation matrix,
> accessible via transform().
>
> I often find it convenient to position the items geometry around the
> origin and instead move the item to where I want it: e.g.:
>
> Item i = new EllipseItem(-8, -8, 16, 16);
> i.move(pos.x(), pos.y());
>
> That will also give you the expected behaviour of pos() and scenePos()
> aftwards.
>
> best regards,
> Gunnar
>
>
_______________________________________________
Qt-jambi-interest mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt-jambi-interest