Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 930
Pieter Avatar asked Dec 17 '22 17:12

Pieter


1 Answers

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.

like image 171
Sussch Avatar answered Dec 27 '22 20:12

Sussch