[Qt-interest] A little confusion about co-ordinates while working with QGraphicsView
Usman Ajmal
uzmanajmal at gmail.com
Tue Jul 14 14:59:25 CEST 2009
Yes, sqMap is a graphicsItem.
No, i'm not reimplementing resize event.
On Tue, Jul 14, 2009 at 5:44 PM, Chandru... <sekarwagmare at gmail.com> wrote:
> if sqMap is graphicsItem ... it will positioned on QGraphicsScene logical
> coordinates only ...
>
> are u reimplementing resize event ... if so check
>
> fitInView(scene->sceneRect(), Qt::KeepAspectRatio);
>
>
>
> On Tue, Jul 14, 2009 at 6:03 PM, Usman Ajmal <uzmanajmal at gmail.com> wrote:
>
>> 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.
>>
>>
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at trolltech.com
>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>>
>>
>
>
> --
> WAGMARE
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090714/9b9f3bee/attachment.html
More information about the Qt-interest-old
mailing list