[PyQt] Re: how to show interactive Picture

Markus Feldmann feldmann_markus at gmx.de
Tue Feb 10 21:42:24 GMT 2009


I go it. :-)

I am not sure, but maybe i have to set a Widget in
the ScrollArea, and in this Widget i may paint?

Here is my Code:
######################################################################
mport sys
from PyQt4.QtGui import QMainWindow,  QDockWidget,  QPainter,  QAction, 
  QScrollArea
from PyQt4.QtGui import QPaintEvent,  QPixmap,  QPen,  QBrush,  QWidget, 
  QLabel
from PyQt4.QtGui import QImage,  QPalette
from PyQt4 import QtCore


class ScrollArea(QScrollArea):
     def __init__(self, parent=None):
         QScrollArea.__init__(self, parent)

         self.imagelabel = QLabel()
         self.image = QImage("./media/images/aventurien.jpg")
         self.imagelabel.setPixmap(QPixmap.fromImage(self.image))
         self.setWidget(self.imagelabel)


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.scrollArea.setBackgroundRole(QPalette.Dark)
         self.setCentralWidget(self.scrollArea)

         self.readSettings()
...

Regards Markus



More information about the PyQt mailing list