Results 1 to 5 of 5

Thread: scroll bars are not appearing

  1. #1
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    387
    Thanks
    101
    Thanked 15 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default scroll bars are not appearing

    I have a QFrame dropArea with QHBoxLayout inside a QScrollArea. Now I drop widgets on it with drag and drop.

    Qt Code:
    1. ui.dropArea->layout()->addWidget(widget);
    2. ui.dropArea->adjustSize();
    To copy to clipboard, switch view to plain text mode 

    I can see the adjustSize() working, the dropArea is growing with every widget I drop. But when it reaches the limit, the scroll bars don't appear like they should. The scroll bar policies are set to the default "as needed" by Designer. What do I need to tweak?

  2. #2
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    387
    Thanks
    101
    Thanked 15 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: scroll bars are not appearing

    I also tried setting a constraint on the layout size

    Qt Code:
    1. layout->setSizeConstraint(QLayout::SetMaximumSize);
    To copy to clipboard, switch view to plain text mode 

    and updating the scroll area manually after the widget has been resized.

    Qt Code:
    1. ui.dropArea->adjustSize();
    2. ui.scrollArea->update();
    To copy to clipboard, switch view to plain text mode 

    Oh and even removing the style sheet. Nothing. No scroll bars.

  3. #3
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    387
    Thanks
    101
    Thanked 15 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: scroll bars are not appearing

    I don't know if I did something wrong, but it seems that adding a widget to a QScrollArea in Designer and then promoting it doesn't do the trick. I had to manually add a widget to the scroll area for the scroll bars to finally appear.

    Qt Code:
    1. ui.scrollArea->setWidget(new DropArea(ui.scrollArea));
    To copy to clipboard, switch view to plain text mode 

    In Designer, first I created a QScrollArea. Then I took a QFrame and dragged it onto the QScrollArea until it was highlighted, so that it was clear that I'm adding the QFrame _to_ it. Then I promoted the QFrame to a DropArea (my custom class). That's the right way to do it isn't it?

    After I spent hours of tinkering with the layout and sizes and the scrollbars just wouldn't appear, I created a minimal example and figured out that only an explicit scrollArea->setWidget(dropArea) will make it work right.

    So then I went back to what I created with Designer and tried to make sure that the dropArea is set as widget of the scrollArea like this:

    Qt Code:
    1. ui.scrollArea->setWidget(ui.dropArea);
    To copy to clipboard, switch view to plain text mode 

    The program crashes without any messages. I also checked if the ui.dropArea and the ui.scrollArea->widget() pointers are the same, they are not. So I think it must be so that Designer doesn't setWidget().

  4. #4
    Join Date
    Jul 2010
    Location
    Ahmedabad,Gujarat,India
    Posts
    25
    Thanks
    14
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: scroll bars are not appearing

    unchecked this property in ui file
    widget Resizable----- unchecked

    then and then u got the scrollarea properly....
    i hope u understand what i want to say u !!

  5. #5
    Join Date
    Sep 2010
    Location
    Portugal
    Posts
    6
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: scroll bars are not appearing

    ui.scrollArea->setWidget(ui.dropArea);

    did the compiler accpted this line?
    Last edited by ralph_pt; 10th September 2010 at 17:32.

Similar Threads

  1. how to add scroll bar on QGridLayout in QT??
    By sharvari in forum Newbie
    Replies: 3
    Last Post: 19th February 2008, 14:31
  2. Adding scroll bars to a main window
    By dougab in forum Newbie
    Replies: 9
    Last Post: 25th December 2007, 20:27
  3. How to find the presence of scroll bars at run time
    By anju123 in forum Qt Programming
    Replies: 8
    Last Post: 28th July 2007, 20:30
  4. QScrollArea's Scroll Bars
    By ToddAtWSU in forum Qt Programming
    Replies: 5
    Last Post: 19th September 2006, 13:27

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.