[PyQt] (no subject)

Mads Ipsen mpi at comxnet.dk
Tue Feb 10 08:36:21 GMT 2009


--------- Original Besked --------
Fra: Markus Feldmann <feldmann_markus at gmx.de>
Til: pyqt at riverbankcomputing.com <pyqt at riverbankcomputing.com>
Emne: [PyQt] Re: how to show interactive Picture
Dato: 09/02/09 23:58

> Mads Ipsen schrieb:
> &gt; Could is be that you try to paint before the window is shown? You
need to
> &gt; call show() before you can start painting. The following snippet
generates
> &gt; an error similar to yours:
> Hi,
>
> This is not all of my Code. So there is a &lt;show()&gt; 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 at 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


More information about the PyQt mailing list