Qt 获取qgraphicscene的大小
我想做以下工作:Qt 获取qgraphicscene的大小,qt,pyqt,Qt,Pyqt,我想做以下工作: 创建QGraphicsView 将其连接到QGraphicscene 获取qgraphicscene的大小 创建具有此大小的QGraphicsRectItem 我的问题是如何获得场景的大小 在所有的例子中,我都看到他们在setscen直立()中放置了常量 下面是我的代码 class CharIdentifierInput(QDialog, Ui_CharIdentifierInput): """description of class""" def __init
class CharIdentifierInput(QDialog, Ui_CharIdentifierInput):
"""description of class"""
def __init__(self, parent):
QDialog.__init__(self, parent)
self.setupUi(self)
self.setFixedSize(self.width(), self.height())
self.leftMouseButtonPressed = False
self.createGui()
def createGui(self):
self.graphicsScene = QGraphicsScene()
self.graphicsView.setScene(self.graphicsScene)
# I want to replace this line with a line that sets to the actual scene size
self.graphicsScene.setSceneRect(0,0,368,235)
mainItem = MyQtCharIdentifierMain(self.graphicsScene.sceneRect())
self.graphicsScene.addItem(mainItem)
mainItem.setPos(0,0)
场景尺寸的获取者是
qgraphicscene.scen直立()
,qgraphicscene.width()
和qgraphicscene.height()
如果SCENERTILT更改,则会发出信号,将新SCENERTIG作为参数发送
如果未设置QGraphicsView.setscen直立()
,则将设置QGraphicsView.scen直立()
返回与
qgraphicscene.scen直立()
相同的值,并随qgraphicscene.scen直立()
而更改,请参见和问题在于,除非向qgraphicscene
添加一个或多个项目,否则它实际上没有大小。如果我想在向其插入项目之前获取场景的大小,我可以从视图中获取大小吗?