[PyQt] QScrollArea test

Russell Valentine russ at coldstonelabs.org
Thu Jan 28 21:34:37 GMT 2010


Christopher Spears wrote:
> I'm trying to add scrollbars to a GUI, so I've been learning about the QScrollArea class.  After reading the online docs and several postings, I wrote a little script for a test:
> 
> #!/usr/bin/env python
> 
> import sys
> from PyQt4 import QtCore, QtGui
> 
> class test(QtGui.QWidget):
>     def __init__(self, parent=None):
>         QtGui.QWidget.__init__(self, parent)
> 	self.setWindowTitle('Test')
> 	self.label = QtGui.QLabel('Label Blah Blah')
> 	self.scrollArea = QtGui.QScrollArea()
> 	self.scrollArea.setWidget(self.label)
> 	hLayout = QtGui.QHBoxLayout()
> 	hLayout.addWidget(self.scrollArea)
> 	self.setLayout(hLayout)
> 	
> app = QtGui.QApplication(sys.argv)
> t = test()
> t.show()
> sys.exit(app.exec_())
> 
> The problem with this script is that the scroll area that is generated does not have any scrollbars.  I played with adjusting the image's size and saw no changes.  Not sure what I am doing wrong...


I took the code you pasted here and when I shrink the window so that the 
label doesn't fit I get scroll bars. You talk about a image so you must 
be doing something you didn't post here?


More information about the PyQt mailing list