[PyQt] Re: how to show interactive Picture
Markus Feldmann
feldmann_markus at gmx.de
Tue Feb 10 17:45:39 GMT 2009
David Boddie schrieb:
> On Tue Feb 10 15:02:13 GMT 2009, Markus Feldmann wrote:
>
>> I think my Problem is that i have to send an envent?
>
> Yes, you need to make a paint event happen. You can do this by calling
> the update() method on the widget you want to be updated.
>
>> As you wrote i changed some of my code. I parted my
>> scrollarea, where i want to paint my picture, and my
>> mainwindow, which is a MDI Sub-Widget. The scrollarea
>> will be centered into the MDI Sub-Widget.
>>
>> class ScrollArea(QScrollArea):
>> def __init__(self, parent=None):
>> QScrollArea.__init__(self, parent)
>>
>> self.pen = QPen()
>> self.brush = QBrush()
>> self.pixmap = QPixmap()
>> self.pixmap.load(":/../media/images/aventurien.jpg")
>>
>> def paintEvent(self, event):
>> painter = QPainter()
>> painter.begin(self)
>> painter.setPen(self.pen)
>> painter.setBrush(self.brush)
>>
>> painter.save()
>> painter.drawPixmap(0, 0, self.pixmap)
>> painter.restore()
>> painter.end()
>
> Looks OK to me.
>
>> class ReiseHelfer(QMainWindow):
>> def __init__(self, parent=None):
>> QMainWindow.__init__(self, parent)
>>
>> self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
>>
>> self.createActions()
>> self.createMenus()
>> self.createStatusBar()
>>
>> self.setWindowTitle(self.tr("Reisehelfer"))
>> self.scrollArea = ScrollArea()
>> self.setCentralWidget(self.scrollArea)
>>
>> self.readSettings()
>
> Does this work? Does it cause the errors you reported in your other message?
>
> David
Yes it works, but with no Picture.
I am reading an example in
/usr/share/doc/python-qt4-doc/examples/painting/basicdrawing
And the example is a little bit different.
It is doing something with the paintevent i think.
It is useful to post my whole Code?
Regards Markus
More information about the PyQt
mailing list