[PyQt] how to show interactive Picture

David Boddie dboddie at trolltech.com
Tue Feb 10 16:15:20 GMT 2009


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


More information about the PyQt mailing list