[PyQt] Drawing on a QFrame
Phil
phil_lor at bigpond.com
Fri Jun 28 06:35:20 BST 2013
Thank you for reading this.
I'd like to draw on a QFrame.
The following does draw a line but not on the frame, instead the line is
drawn on the main window.
I've done this years ago with Qt and C++ but I don't remember how I did it.
class DrawTest(QtGui.QMainWindow):
def __init__(self, parent=None):
super(DrawTest, self).__init__(parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
frame = QtGui.QFrame()
def paintEvent(frame, event):
qp = QtGui.QPainter()
qp.begin(frame)
pen = QtGui.QPen(QtCore.Qt.yellow, 4)
qp.setPen(pen)
frame.drawLine(event, qp)
qp.end()
def drawLine(frame, event, qp):
qp.drawLine(10, 10, 30, 30)
--
Regards,
Phil
More information about the PyQt
mailing list