Qt-interest Archive, May 2007
QGraphicsItemSize ?
Message 1 in thread
Hi,
I have a QGraphicsItem and I want to know its co-ordinates.
I know I can do it by pos(). I was just trying one other way.
From the GraphicsView I do :-
QRectF rect = m_connectorOrigin->rect();
int xR = rect.x();
int yR = rect.y();
The xR and yR are always zero.
Why is that ?
I believe xR and yR should be the co-ordinates in the view co-ordinate
system of the top-left corner ?
If not, rect.x() and rect.y() would always be zero.
Pl lemme know if I am missing out some criticial link here...
Thanx
Prateek
Message 2 in thread
Prateek Tiwari schrieb:
> Hi,
>
> I have a QGraphicsItem and I want to know its co-ordinates.
> I know I can do it by pos(). I was just trying one other way.
> From the GraphicsView I do :-
>
> QRectF rect = m_connectorOrigin->rect();
> int xR = rect.x();
> int yR = rect.y();
>
> The xR and yR are always zero.
> Why is that ?
> I believe xR and yR should be the co-ordinates in the view co-ordinate
> system of the top-left corner ?
> If not, rect.x() and rect.y() would always be zero.
>
> Pl lemme know if I am missing out some criticial link here...
>
> Thanx
> Prateek
>
>
>
...what kind of object is m_connectorOrigin ? QGraphicsItem has no
rect() method as far as I can see...
If there was rect() would always sit on (0, 0) as these methods always
deliver local coordinates.
You will have to transform them to scene coordinates, if you want to use
them in relation to the view.
See here:
http://doc.trolltech.com/4.2/graphicsview.html#the-graphics-view-coordinate-system
HTH
Daniel
--
[ signature omitted ]