PDA

View Full Version : How do I get the inner dimensions of a QGraphicsView?



wayfaerer
6th February 2012, 02:19
I'm a bit confused about how to get the inner dimensions (scrollable area) of a QGraphicsView in pixels. I've seen several posts about how to get the size of the QGraphicsView itself in terms of how much space it takes up on the screen, but I need its inner dimensions.

I keep thinking it might be QGraphicsView::sceneRect, but I don't think that is right. For example, if I use QGraphicsView::scale to zoom in, then the QGraphicsView's inner dimensions will have grown, but the underlying scene will not have grown.

Am I missing something?

Added after 56 minutes:

I always forget to look in the inherited members. *sigh*

It seems as though the correct way to do this is to call QAbstractScrollArea::maximumViewportSize(). Someone please correct me if I'm wrong.

wayfaerer
6th February 2012, 17:15
Hm, no, maximumViewportSize() doesn't seem to do it.

wysota
6th February 2012, 18:29
viewport()->size() should do it. Of course you need to call it after the widget is already visible. maximumViewportSize() should also do the trick, you are probably calling it too early.