PDA

View Full Version : QScrollArea doesn't expand as I would expect



Pepe
16th December 2008, 01:37
I'm implementing a widget which displays several images in a table. This widget is in a QScrollArea (so it could provide scrollbars when needed), and finally this QScrollArea is in another widget (the window).

I expect that the initial size of the window would be big enough so all the images could be seen without scrollbars. But that doesn't happen, the window is quite small.

I tried with setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding) (for both the QScrollArea and the window) but it doesn't make any difference. I also tried with adjustSize() and updateGeometry() but there's no change.

This is what I got:
http://e.imagehost.org/t/0251/scrollarea1.jpg (http://e.imagehost.org/view/0251/scrollarea1)

But I would expect something like this:
http://e.imagehost.org/t/0560/scrollarea2.jpg (http://e.imagehost.org/view/0560/scrollarea2)

I attach a small sample code which demonstrates the problem.
Is there any way to fix it?

jpn
26th December 2008, 12:59
I'm afraid you have to subclass QScrollArea and reimplement sizeHint() to return the size hint of the content widget plus frame widths or so.