On Fri, 28 Jun 2013 15:35:20 +1000, Phil <phil_...@bigpond.com> wrote: > 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) Sub-class the frame and reimplement its paintEvent(). Also make sure the frame isn't being garbage collected (like it is above) and add it to the GUI somewhere. Phil _______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt