bspitz
26th April 2011, 10:43
Hi all,
I'm having troubles stretching QGraphicsViews automatically when the size of my window adjusts.
This is the code I have at the moment.
self.leftview = QtGui.QGraphicsView()
self.rightview = QtGui.QGraphicsView()
self.leftview.setFixedSize(550,600)
self.rightview.setFixedSize(550,600)
leftrect = QtCore.QRectF(self.leftview.rect())
rightrect = QtCore.QRectF(self.rightview.rect())
leftrect.adjust(1,1,-1,-1)
rightrect.adjust(1,1,-1,-1)
self.leftscene = TEMDrawer.DiagramScene(leftrect)
self.rightscene = TEMDrawer.DiagramScene(rightrect)
self.leftview.setScene(self.leftscene)
self.rightview.setScene(self.rightscene)
The constructor of the DiagramScene calls the setSceneRect with the given parameter.
No GUI-related stuff other than that happens in the DiagramScene class.
Removing the setFixedSize() method calls do not enable automatic stretching of the QGraphicsView or QGraphicsScene.
Is there a way to automatically stretch a QGraphicsScene or QGraphicsView to fit the space the layout uses?
Thanks in advance!
PS: I had a look at the proposed threads #1 (http://www.qtcentre.org/threads/11901-Problem-determining-size-of-QGraphicsView)#2 (http://www.qtcentre.org/threads/9803-Setting-the-scene-size-in-QGraphicsView)#3 (http://www.qtcentre.org/threads/9498-Size-of-QGraphicsView), but they did not offer a solution for my problem...
I'm having troubles stretching QGraphicsViews automatically when the size of my window adjusts.
This is the code I have at the moment.
self.leftview = QtGui.QGraphicsView()
self.rightview = QtGui.QGraphicsView()
self.leftview.setFixedSize(550,600)
self.rightview.setFixedSize(550,600)
leftrect = QtCore.QRectF(self.leftview.rect())
rightrect = QtCore.QRectF(self.rightview.rect())
leftrect.adjust(1,1,-1,-1)
rightrect.adjust(1,1,-1,-1)
self.leftscene = TEMDrawer.DiagramScene(leftrect)
self.rightscene = TEMDrawer.DiagramScene(rightrect)
self.leftview.setScene(self.leftscene)
self.rightview.setScene(self.rightscene)
The constructor of the DiagramScene calls the setSceneRect with the given parameter.
No GUI-related stuff other than that happens in the DiagramScene class.
Removing the setFixedSize() method calls do not enable automatic stretching of the QGraphicsView or QGraphicsScene.
Is there a way to automatically stretch a QGraphicsScene or QGraphicsView to fit the space the layout uses?
Thanks in advance!
PS: I had a look at the proposed threads #1 (http://www.qtcentre.org/threads/11901-Problem-determining-size-of-QGraphicsView)#2 (http://www.qtcentre.org/threads/9803-Setting-the-scene-size-in-QGraphicsView)#3 (http://www.qtcentre.org/threads/9498-Size-of-QGraphicsView), but they did not offer a solution for my problem...