[PyQt] image with scrollbars in a qlabel how ?

Joachim Schmitz js at aixtraware.de
Thu Nov 15 18:55:08 GMT 2007


David Boddie schrieb:

> 
> I wrote a quick test to see what was needed to get this to work:
> 
> from PyQt4.QtGui import *
> 
> class ImageViewer(QWidget):
> 
>     def __init__(self, parent = None):
>     
>         QWidget.__init__(self, parent)
>         area = QScrollArea()
>         self.label = QLabel()
>         area.setWidget(self.label)
>         layout = QVBoxLayout()
>         layout.addWidget(area)
>         self.setLayout(layout)
>     
>     def setImage(self, image):
>     
>         self.label.setPixmap(QPixmap.fromImage(image))
>         self.label.adjustSize()
> 
> Does this help?


Thanks it helped, the main mistake I made was:

you example has:  layout.addWidget(area)

i had:  layout.addWidget(self.label)

as soon as I did it right, it worked ;-)


thanks again.




-- 
Gruß Joachim


More information about the PyQt mailing list