I am supposed to add scrollbars to the screen. The class design shown below is the part of a software that I am supposed to modify and add scrollbars to. The scroll bar code in Window class has been added by me.

It doesn't get shown when I run the program. What am I supposed to correct?


Qt Code:
  1. import sys
  2.  
  3. from PyQt4 import QtGui
  4. from PyQt4 import QtCore
  5.  
  6. class Window(QtGui.QGraphicsView):
  7.  
  8. def __init__(self, parent=None):
  9.  
  10. QtGui.QGraphicsView.__init__(self, parent)
  11. self.scene = QtGui.QGraphicsScene(self)
  12. self.scene.setBackgroundBrush(QtGui.QBrush(QtCore.Qt.darkGray, QtCore.Qt.SolidPattern))
  13. self.setScene(self.scene)
  14.  
  15. self.setDragMode(QtGui.QGraphicsView.ScrollHandDrag)
  16. self.setTransformationAnchor(QtGui.QGraphicsView.AnchorUnderMouse)
  17. self.viewport().setCursor(QtCore.Qt.CrossCursor)
  18. self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
  19. self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
  20.  
  21. print "sdsads"
  22.  
  23.  
  24. class CityscapesLabelTool(QtGui.QMainWindow):
  25. def __init__(self, parent=None):
  26.  
  27. QtGui.QMainWindow.__init__(self, parent)
  28. Window()
  29.  
  30. app = QtGui.QApplication(sys.argv)
  31. GUI = CityscapesLabelTool()
  32. GUI.show()
  33. sys.exit(app.exec_())
To copy to clipboard, switch view to plain text mode