[PyQt] QPainter

David Boddie david at boddie.org.uk
Thu Jun 21 23:37:18 BST 2007


On Thu Jun 21 09:05:32 BST 2007, lucaberto wrote:

> Hello using pyqt3 for paint when i click one qbutton i do as follow
> 
> gr = QPainter(self.frame3)
> gr.drawLine(30,10,30,490)
> and the line is draw. 
> 
> if i do the same with pyqt4 nothing is draw can you explain me how to
> proceed

For various reasons, Qt 4 introduced some restrictions on painting which
prevent direct drawing onto widgets from outside their paintEvent()
implementations.

This means that you will either have to subclass QFrame, provide a
paintEvent() method, and figure out some way to tell it what to draw,
or you can use a QLabel and pass it a QPixmap or QPicture that you have
drawn on.

David


More information about the PyQt mailing list