[Qt-interest] A little confusion about co-ordinates while working with QGraphicsView
Usman Ajmal
uzmanajmal at gmail.com
Tue Jul 14 14:33:34 CEST 2009
Hi,
I have a little confusion about QGraphicsView and the co-ordinates of my
shapes (e.g. a rectangle) in it. I hope someone may clear it out to me.
Geometery of my graphics view is graphicsView->setGeometry(QRect(10, 10,
710, 540));
This mean Width = 710 - 10 = 700
and Height = 540 - 10 = 530
As 700/2 = 350 and 530/2 = 265 and because i want to set my scene equal to
the height and width of graphicsView. Therefore i set my scene as:
scene->setSceneRect(-350,-265,700,530);
Now i want to draw a rectangle os some size (say 50) and want it be drawn
such that its top-left corner appears at top-left corner of my graphicsView
so i wrote following lines of code
sqMap *square = new sqMap(50);
square->setPos(-350,-265);
By doing so nothing appears but by setting position as under i get my
rectangle at the desired location.
square->setPos(-353,-6);
Can anyone please guide me what the point here i am missing? I hope the
bounding rectangle is not creating any problem here.
Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090714/eb8ea728/attachment.html
More information about the Qt-interest-old
mailing list