[PyKDE] Newbie Problem using QScrollArea

Andreas Pakulat apaku at gmx.de
Thu Dec 7 23:20:55 GMT 2006


On 07.12.06 14:55:07, Brent Villalobos wrote:
> I'm still not understanding the secret to using QScrollArea with other
> widgets.  What I have is a GUI that has two group boxes -- one that contains
> control widgets and the other contains an arbitrary number of  image
> thumbnails.

Then forget about QScrollArea and look at QListView. Its able to display
an arbitrary number of Pixmaps, i.e. thumbnails. And it handles all the
layouting/scrollbar stuff. Actually for Qt4 and simple QPixmaps
QListWidget might be enough, so you don't need to delve into model/view.

> All the QScrollArea examples I've run across say that I should be able to do
> something like this:
> scrollArea = QtGui.QScrollArea()
> scrollArea.setWidget(self.thumbnailsGroupBox)

That would bring the group box inside the scroll area, meaning that if
the group box grows too large the scrollbars appear.

If you want scrollbars inside the groupbox, add the QScrollArea as child
of the Group Box. Then create a QWidget that holds all your thumbnails
in whatever layout you want and add that QWidget to the QScrollArea
using setWidget. But this is more or less what the QListWidget is doing
(except it does the drawing itself, instead of using a QWidget or
QLabel).

Andreas

-- 
Executive ability is prominent in your make-up.




More information about the PyQt mailing list