0

I fit my scene for view's size, but it's content has some margins on right and bottom sides.

m_ui.graphicsView->fitInView(m_scene->sceneRect(), Qt::IgnoreAspectRatio);

Can I avoid this behavior?

enter image description here

Eugene
  • 588
  • 1
  • 8
  • 20
  • 1
    Might be wrong, but depending on your used layouter where you put your graphics view in, this is a margin between the different elements. And if you use a QMainWindow the centralWidget also has a margin. Check [this](http://stackoverflow.com/questions/16572344/space-between-widgets-in-qvboxlayout) question and see if that helps you. – dowhilefor Nov 20 '13 at 12:00
  • No, QGraphicalsView is in grid layout without margins, viewport also without it. This margin is inside view. I tryed set it. Maybe it is possible to set view resizeEvent filter on element? But I can't find any functions for it in QGraphicsItem. – Eugene Nov 20 '13 at 13:04

1 Answers1

0

I think you're misunderstanding the point of the fitInView function. it's there to ensure that the given rect area of the scene is visible in the view. As the docs state: -

Scales the view matrix and scrolls the scroll bars to ensure that the scene rectangle rect fits inside the viewport. rect must be inside the scene rect; otherwise, fitInView() cannot guarantee that the whole rect is visible.

TheDarkKnight
  • 27,181
  • 6
  • 55
  • 85