Reputation: 1275
I want to do the following:
My problem is how to get the size of the scene In all the examples I saw that they put constants in setSceneRect() The following is my code
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)
Upvotes: 1
Views: 5645
Reputation: 4286
Getters of the dimensions of the sceneRect are
QGraphicsScene.sceneRect()
, QGraphicsScene.width()
and QGraphicsScene.height()
if the sceneRect changes, QGraphicsScene.sceneRectChanged
-signal is emitted, sendig the new sceneRect as parameter.
If QGraphicsView.setSceneRect()
is not set, QGraphicsView.sceneRect()
will
return the same value as QGraphicsScene.sceneRect()
and it changes with QGraphicsScene.sceneRect()
, see documentation QGraphicsView and documentation QGraphicsScene
Upvotes: 2