--------- Original Besked -------- Fra: Markus Feldmann <feldmann_mar...@gmx.de> Til: pyqt@riverbankcomputing.com <pyqt@riverbankcomputing.com> Emne: [PyQt] Re: how to show interactive Picture Dato: 09/02/09 23:58
> Mads Ipsen schrieb: > > Could is be that you try to paint before the window is shown? You need to > > call show() before you can start painting. The following snippet generates > > an error similar to yours: > Hi, > > This is not all of my Code. So there is a <show()> in my main source > code. This Source Code only shows a sub-widget of a MDI Application. > > However this window is shown, but without the picture. > How do the program know in which widget shall the Pixmap > be shown ? > > _______________________________________________ > PyQt mailing list PyQt@riverbankcomputing.com > http://www.riverbankcomputing.com/mailman/listinfo/pyqt > Thats something you tell the program. You reimplement the method 'paintEvent' for a widget class like in the example I posted. Then for a particular instance of the widget, the window is painted everytime a paintEvent occurs and the widget get painted. A paintEvent event occurs eg. when a window is hidden underneath another window and then shown. To a draw a pixmap onto a widget do something like this in the paintEvent method: def paintEvent(self, event): painter = QtGui.QPainter(64,64) pixmap = QtGui.QPixmap() painter.begin(self) painter.drawPixmap(0,0,pixmap) painter.end() Mads _______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt