Getting the size of a QGraphicsView

后端 未结 5 1920
眼角桃花
眼角桃花 2021-01-20 14:07

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->myGra

5条回答
  •  滥情空心
    2021-01-20 14:41

    Answer: After calling MainWindow::show(), then get the size.

    Description: I had the same problem as Pieter. In the widget constructor like MainWindow::MainWindow() you can't get the correct size of the widget like QGraphicsView in Grid Layout because in that constructor the widget's size and location are not determined. Therefore, in MainWindow::MainWindow() you have to call show() and then get the size of the view or other widget.

提交回复
热议问题