Get visible rectangle of QGraphicsView?

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

    Nevermind. Came up with this, which seems to work.

    QRectF EditorView::visibleRect() {
        QPointF tl(horizontalScrollBar()->value(), verticalScrollBar()->value());
        QPointF br = tl + viewport()->rect().bottomRight();
        QMatrix mat = matrix().inverted();
        return mat.mapRect(QRectF(tl,br));
    }
    

提交回复
热议问题