I have this screen:
On it I draw a line which goes out of the board:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
from PyQt4 import QtGui, QtCore
class Example(QtGui.QWidget):
def __init__(self):
super(Example, self).__init__()
self.initUI()
def initUI(self):
self.drawingPanel = DrawingPanel(self)
verticalLayout = QtGui.QVBoxLayout( self )
verticalLayout.addWidget(self.drawingPanel)
self.setLayout( verticalLayout )
# self.setGeometry(300, 300, 400, 300)
self.resize( 400, 300 )
self.setWindowTitle('Review')
self.show()
class DrawingPanel(QtGui.QGraphicsView):
def __init__(self, parent):
QtGui.QGraphicsView.__init__(self, parent)
self.setScene(QtGui.QGraphicsScene(self))
self.setSceneRect(QtCore.QRectF(self.viewport().rect()))
# self.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Maximum)
pencil = QtGui.QPen(QtCore.Qt.black, 2, QtCore.Qt.SolidLine)
pencil.setStyle(QtCore.Qt.DotLine)
self.scene().addLine(QtCore.QLineF(0, 0, 300, 600), pencil)
def main():
app = QtGui.QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())
if __name__ == '__main__':
main()
How to make the panel create a scroll bar and be able to show the whole line drawn?
I could find some other questions as: