Results 1 to 2 of 2

Thread: QScrollArea doesn't expand as I would expect

  1. #1
    Join Date
    Mar 2007
    Posts
    58
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default QScrollArea doesn't expand as I would expect

    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:


    But I would expect something like this:


    I attach a small sample code which demonstrates the problem.
    Is there any way to fix it?
    Attached Files Attached Files
    Last edited by Pepe; 16th December 2008 at 01:47.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QScrollArea doesn't expand as I would expect

    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.
    J-P Nurmi

Similar Threads

  1. Replies: 2
    Last Post: 8th October 2006, 20:14

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.