Get visible rectangle of QGraphicsView?

前端 未结 6 1459
借酒劲吻你
借酒劲吻你 2020-12-15 22:04

I\'ve been pulling my hair out with this one for hours. There\'s a thread here about it, but nothing seems to be working. QGraphicsView::rect() will return the width and hei

6条回答
  •  悲&欢浪女
    2020-12-15 22:29

    You can do what you've done, or use the mapToScene() functions. You can't count on the resulting scene "rectangle" being a rectangle, however, because the scene might be rotated or sheared in the view, resulting in a general polygon when mapped to the scene.

    If your application never does such things, of course, you're free to assume that a rectangle is always appropriate.

提交回复
热议问题