[PyQt] Pb understanding painter

Jean-Baptiste BUTET ashashiwa at gmail.com
Sat Dec 22 08:58:48 GMT 2007


Hi all :)

I am trying to draw a cross in a label with coordinates.

I've think (surely false ;) ) make a a widget, place it on coodinates and
paint it with my cross Image.

here is this code :
class point(QtGui.QWidget):

    def __init__(self, x, y, parent):
        print "parti"
        QtGui.QWidget.__init__(self, parent)
        self.x = x
        self.y = y
    def paintEvent(self, event):
        print "parti_"

        painter = QtGui.QPainter(self)
        print "painter_ok"
        painter.setPen(QtCore.Qt.black)
        painter.drawImage(QtCore.QPoint(self.x,self.y), QtGui.QImage("
croix.png"))


I call my widget with : point_draw = point(x,y,
self.ui.label_where_to_draw_my_widget)

When I do this, I could see my paintEvent is launched (print "parti_") but
nothings happens on my label.

Why ?

Thanks.

JB

-- 
http://astrolix.org
association des linuxiens astronomes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20071222/b3ba0305/attachment.html


More information about the PyQt mailing list