Results 1 to 4 of 4

Thread: QScrollArea Confusion

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2010
    Location
    Pennsylvania, USA
    Posts
    36
    Thanks
    9
    Thanked 3 Times in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QScrollArea Confusion

    I'm trying to learn to use a QScrollArea, but I'm obviously missing some important step.

    Using Qt Creator (or designer, it doesn't matter), I create a QMainWindow and add a QScrollArea. I then drop a standard "Widget" into the QScrollArea (and set its style sheet to "background: red;" just so I can see it), and add a standard push button.

    I add the following slot to the button:
    Qt Code:
    1. void MainWindow::on_pushButton_clicked()
    2. {
    3. ui->widget->resize(5000, ui->widget->height());
    4. }
    To copy to clipboard, switch view to plain text mode 
    (The rest of the code is generated by Creator, but I can provide it if requested.)

    My anticipated behavior is: when I click the button, it will re-size the child widget, thereby causing the scroll area to adjust its scroll bars--in this case only the horizontal bar. Unfortunately, that doesn't happen. I can tell that clicking the button does re-size the child widget, but the scroll area's scroll bars do not update--no handles appear, and the entire scroll bar remains gray, as if disabled.

    I have tried enabling the scroll bar, with no effect. I ensured widgetResizable is set to false, but that didn't effect the result either. I originally thought a layout I was using for the child widget was causing the problem, but removing it didn't change the result. The way I understand (or maybe misunderstand) the documentation, by default a QScrollArea should respect the size of its child, and adjust the scroll bars automatically. What did I miss?
    Last edited by TheJim01; 24th March 2010 at 14:23.

Similar Threads

  1. confusion city
    By Petr_Kropotkin in forum Newbie
    Replies: 1
    Last Post: 3rd February 2010, 15:30
  2. Class Confusion
    By Petr_Kropotkin in forum Newbie
    Replies: 5
    Last Post: 23rd January 2010, 15:23
  3. QwtPlotMarker confusion
    By baray98 in forum Qwt
    Replies: 3
    Last Post: 20th July 2008, 09:47
  4. Replies: 2
    Last Post: 10th March 2008, 20:16
  5. QLocale confusion :(
    By gri in forum Qt Programming
    Replies: 6
    Last Post: 15th June 2007, 13:09

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.