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?
import sys
from PyQt4 import QtGui
from PyQt4 import QtCore
def __init__(self, parent=None):
self.
scene.
setBackgroundBrush(QtGui.
QBrush(QtCore.
Qt.
darkGray, QtCore.
Qt.
SolidPattern)) self.setScene(self.scene)
self.
setTransformationAnchor(QtGui.
QGraphicsView.
AnchorUnderMouse) self.viewport().setCursor(QtCore.Qt.CrossCursor)
self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
print "sdsads"
def __init__(self, parent=None):
Window()
GUI = CityscapesLabelTool()
GUI.show()
sys.exit(app.exec_())
import sys
from PyQt4 import QtGui
from PyQt4 import QtCore
class Window(QtGui.QGraphicsView):
def __init__(self, parent=None):
QtGui.QGraphicsView.__init__(self, parent)
self.scene = QtGui.QGraphicsScene(self)
self.scene.setBackgroundBrush(QtGui.QBrush(QtCore.Qt.darkGray, QtCore.Qt.SolidPattern))
self.setScene(self.scene)
self.setDragMode(QtGui.QGraphicsView.ScrollHandDrag)
self.setTransformationAnchor(QtGui.QGraphicsView.AnchorUnderMouse)
self.viewport().setCursor(QtCore.Qt.CrossCursor)
self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
print "sdsads"
class CityscapesLabelTool(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QMainWindow.__init__(self, parent)
Window()
app = QtGui.QApplication(sys.argv)
GUI = CityscapesLabelTool()
GUI.show()
sys.exit(app.exec_())
To copy to clipboard, switch view to plain text mode
Bookmarks