[Qt-interest] QGraphicsScene pos
pmqt71
pmqt71 at gmail.com
Tue Oct 26 11:28:20 CEST 2010
Ok, thanks a lot.
I actually was expecting this behaviour without calling any fitInView
method.
Just another question:
I have the QRectF -50.0, -50.0, 50.0, 50.0
the width is 50??
qDebug() << "width=" << rect.width(); //returns 50
thanks
pm
2010/10/26 Sean Harmer <sean.harmer at maps-technology.com>
> Hi,
>
> > myScene->setSceneRect( -50.0, -50.0, 50.0, 50.0 );
> > on the following event handler, I want the x and y within the scene rect.
>
> > void MyGraphicsScene::mouseDoubleClickEvent ( QGraphicsSceneMouseEvent *
> > mouseEvent)
> > {
> > QRectF rect = sceneRect(); //this gives -50.0, -50.0, 50.0, 50.0
> >
> > //but the following returns something out of the sceneRect - e.g.
> 106,
> > -91 double-clicking in the top right corner
> >
> > QPointF pointScene = mouseEvent->lastScenePos ();
> >
> > // is it a view related point?
> > QPointF point = this->views()[0]->mapToScene(pointScene.toPoint()); //
> > but this returns -51, -183
> > }
> >
> > The QGraphicsView is added into a layout and the mainWindow is resizable,
> > so the size of the widget is not fixed.
>
> By default the scene is displayed in the view at a scale of 1.0. So if your
> view's viewport is larger than 100x100 pixels then it will be displaying
> regions outside of your scenerect so the above code and results looks
> feasible
> to me.
>
> If you want your scene to fill your view you will need to call
> QGraphicsScene::fitInView() to change the view transformation before you
> start
> double-clicking.
>
> This type of thing is much easier to visualise if you add a small rect at
> each
> corner of your scene rect for example.
>
> HTH,
>
> Sean
>
> >
> >
> >
> > thanks
> >
> > pm
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20101026/3e13f64c/attachment.html
More information about the Qt-interest-old
mailing list