Getting the size of a QGraphicsView

后端 未结 5 1919
眼角桃花
眼角桃花 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:31

    I have the same problem with you. QGraphicsView.size() is always return (100,30). I have solved this problem in my project.

    Check below code is like this

    ...in a QTabWidget class...
    def addANewTab(self):
      view = QGraphicsView()
      ...set view param...
      index = self.addTab(view, 'test')
      view.size() # it will return (100,30)
      self.setCurrentIndex(index)
      view.size() # it will return correct size
    

    so like Bigbell Mercy answered , you show make sure QGraphicsView is show!

提交回复
热议问题