Monday, 15 February 2010

qt - how to set exact scene rect in QGraphicsView -


I have a problem with QGraphicsView, I do not know how to set the exact viewport for QGraphicsView. For example, Was written:

  QGraphicsScene * view = new QGraphicsScene (); QGraphicsEllipseItem * Oval; Q-Pen (QT :: Red); Qbrush Brush (Qt :: Neela); Oval = Scene-> Allepse (10,10,100,100,100,100, pen, brush); UI- & gt; GraphicsView-> SetScene (view); UI- & gt; GraphicsView-> SetSceneRect (10,10,100,100);  

I think there should be a circle to see the result in which its diameter is equal to the height or width of the viewport. But when I run the program, it shows me inside of a middle-sized circle, which means that the graphicview's view is bigger than I have specified. Why do I know any body?

I found a solution for myself: Suppose the exact graphs are the exact rectangle that you want to zoom in To:

  QRectF exact search (20, 10, 300, 200); UI- & gt; GraphicsView-> SetSceneRect (exactRect); UI- & gt; GraphicsView-> SetCenterOn (exactRect.center ()); Quatrates MTX; Mtx.scale (ui- & gt; Graphicsview- & gt; width () / exactcart (), ui- & gt; graphicsview-> height () / exact.height ()); UI- & gt; GraphicsView-> SetMatrix (MTX);  

No comments:

Post a Comment