Results 1 to 8 of 8

Thread: Container widget with scrollbars

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Container widget with scrollbars

    Use this:
    Qt Code:
    1. QScrollView * sv = new QScrollView( this );
    2. QWidget * w = new QWidget(sv->viewport());
    3. w->setPaletteBackgroundColor(Qt::white);
    4. sv->addChild(w);
    5. sv->setResizePolicy(QScrollView::AutoOneFit);
    To copy to clipboard, switch view to plain text mode 

    The magic line is the resize policy, which causes your widget to be resized to the viewport size. The result is fine, but not perfect. Something is messed up with the widget height, but I didn't want to get into the code too deep. I'm sure you'll manage to fix it. It's probably caused by heightForWidth in the layout.

  2. The following user says thank you to wysota for this useful post:

    a550ee (28th September 2006)

Similar Threads

  1. Container Extensions
    By mariok in forum Qt Programming
    Replies: 1
    Last Post: 3rd July 2007, 11:06
  2. Pin/Unpin Dock Widget
    By charlesD in forum Newbie
    Replies: 1
    Last Post: 21st June 2006, 06:57
  3. Replies: 4
    Last Post: 24th March 2006, 22:50
  4. [Qt 4.1.0] Split a widget on demand
    By Townk in forum Qt Programming
    Replies: 3
    Last Post: 17th February 2006, 14:16
  5. advanced split widget
    By vitaly in forum Qt Programming
    Replies: 10
    Last Post: 24th January 2006, 20:00

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.