Search code examples
c++qtqgraphicsview

Getting the size of a QGraphicsView


I want to know the size of a certain QGraphicsView. Its size isn't fixed because the widget is part of a grid layout. I tried using this->ui->myGraphicsView->width() and its height equivalent but these values aren't accurate.

How can I get the current size of a QGraphicsView?


Solution

  • Constantly received 100x30 as the size of my QGraphicsView as well. It turned out I was asking for the size of the QGraphicsView before it was shown.

    After moving my initialization code to showEvent, I got the correct dimensions.