Get visible rectangle of QGraphicsView?

前端 未结 6 1475
借酒劲吻你
借酒劲吻你 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:34

    here is a possible solution (no clue whether this is the intended one)

    QRectF XXX::getCurrrentlyVisibleRegion() const
    {
            //to receive the currently visible area, map the widgets bounds to the scene
    
            QPointF topLeft = mapToScene (0, 0);
            QPointF bottomRight = mapToScene (this->width(), this->height());
    
            return QRectF (topLeft, bottomRight);
    }
    

    HTH, Bernhard

提交回复
热议问题